Page 1 of 1

Assertion fail

Posted: Mon 23 Feb 2015 15:23
by jan.drozen
Hello,
we are looking for some ORM framework and we are considering to use EntityDAC. So I downloaded and installed the trial version to test some features. I wrote a very simple example:

Code: Select all

unit entityDACtest;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  EntityDAC.Entity,
  EntityDAC.EntityConnection,
  EntityDAC.EntityAttributes,
  EntityDAC.EntityContext,
  EntityDAC.DataProvider.FireDAC,
  EntityDAC.MetaEntity,
  EntityDAC.NullableTypes,
  EntityDAC.Types,
  EntityDAC.Utils,
  FireDAC.Stan.Def,
  FireDAC.Phys.MSSQL,
  FireDAC.DApt,
  FireDAC.VCLUI.Wait,
  FireDAC.Stan.Async;

type

	[Table('dbo.GTW_WORKFLOWS')]
  [Model('WorkflowModel')]
  [Key('FWorkflowid')]
  TGTWWorkflow = class(TMappedEntity)
  private
    [Column('workflowid')]
    FWorkflowid: Integer;
    [Column('typeid')]
    FTypeid: Integer;
    [Column('WF_name', 255, [CanBeNull])]
    FWfName: String;
  end;
  TForm1 = class(TForm)
    procedure onCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.onCreate(Sender: TObject);
var
	Lconnection: TEntityConnection;
  Lcontext: TEntityContext;
  Lworkflows: IEntityEnumerable<TGTWWorkflow>;
  Lworkflow : TGTWWorkflow;
begin
	Lconnection := TEntityConnection.Create;
  Lconnection.ProviderName := 'FireDAC';
  Lconnection.DialectName := 'SQL Server';
  Lconnection.ConnectionString := 'Data Provider=FireDAC;SQL Dialect=SQL Server;Login Prompt=False;DriverID=MSSQL;Server=127.0.0.1;Database=GTWtest;User_name=sa;Password=*********';
  Lconnection.Connect;
  Lcontext := TEntityContext.Create;
  Lcontext.Connection := Lconnection;
  Lcontext.ModelName := 'WorkflowModel';

   Lworkflows := Lcontext.GetEntities<TGTWWorkflow>;
   for Lworkflow in Lworkflows do
   begin
      ShowMessage(Lworkflow.FWfName);
   end;

end;

initialization

  ForceRtti(TGTWWorkflow);

end.
When calling the Lcontext.GetEntities<> the program crashes on assertion failure:

---------------------------
Debugger Exception Notification
---------------------------
Project entityDACproj.exe raised exception class EAssertionFailed with message 'Assertion failure (D:\Projects\Delphi\EntityDac\Source\EntityDAC.Entity.pas, line 319)'.
---------------------------
Break Continue Help
---------------------------

I'm a bit confused since there is no such path in my computer (there is not a drive D).
Can you please give me a way how to repair this example to working state?

Lot of thanks.

Re: Assertion fail

Posted: Tue 24 Feb 2015 12:24
by AlexP
Hello,

This occurs, because you haven't redefined your class constructor. You can find a constructor sample in the documentation: http://www.devart.com/entitydac/docs/democlassespas.htm .

Re: Assertion fail

Posted: Thu 26 Feb 2015 15:12
by jan.drozen
Hello Alex,
thank you for your solution. It has worked after some additional fixes.
Can you please refer to any other point in documentation or reference, where is stated how and why is needed to redefine the ctors?

Re: Assertion fail

Posted: Mon 02 Mar 2015 10:42
by AlexP
See information about the TMappedEntity class constructor at http://www.devart.com/entitydac/docs/de ... create.htm .