Assertion fail

Assertion fail

Postby jan.drozen » Mon 23 Feb 2015 15:23

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.
jan.drozen
 
Posts: 3
Joined: Mon 23 Feb 2015 15:15

Re: Assertion fail

Postby AlexP » Tue 24 Feb 2015 12:24

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 .
AlexP
Devart Team
 
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Assertion fail

Postby jan.drozen » Thu 26 Feb 2015 15:12

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?
jan.drozen
 
Posts: 3
Joined: Mon 23 Feb 2015 15:15

Re: Assertion fail

Postby AlexP » Mon 02 Mar 2015 10:42

See information about the TMappedEntity class constructor at http://www.devart.com/entitydac/docs/devart_entitydac_tentity_create.htm .
AlexP
Devart Team
 
Posts: 5530
Joined: Tue 10 Aug 2010 11:35


Return to EntityDAC