I have any existing Firebird database with a table that has an autogenerated integer primary key id field. I am using the UniDac components with IBDAC. How can I configure Aurelius to support my situation? If I define the id field as "[Id('FID', TIdGenerator.IdentityOrSequence ]" and try to add a record I get "Auto generated values are not supported on Firebird SQL generator". If I change the id property to TIdGenerator.None I get "Id is not set on entity of class TMyClass".
From what I know Firebird doesn't have identity fields, that's why the error message. What is the table definition?
Here is the class:
[Entity]
[Id('FLEADID', TIdGenerator.{IdentityOrSequence }None)]
TLead = class
private
[Column('LEADID', [TColumnProp.Unique, TColumnProp.Required, TColumnProp.NoUpdate, TColumnProp.NoInsert])]
FLeadId: integer;
// MFKGuid: string;
FMFKCTS: TDateTime;
FMFKLMTS: TDateTime;
FLeadSource: nullable<string>;
FLeadSourceId: nullable<string>;
FFirstName: nullable<string>;
FLastName: nullable<string>;
FStreet: nullable<string>;
FCity: nullable<string>;
FState: nullable<string>;
FZipCode: nullable<string>;
FHomePhone: nullable<string>;
FLeadAvailable: byte;
FLeadAcceptedBy: integer;
FProduct: nullable<string>;
FCampaignId: integer;
FUploadedToLeadMgmt: byte;
FMarketingId: integer;
FTheUniqueId: nullable<string>;
public
[Column('MFK$CTS', [TColumnProp.NoUpdate, TColumnProp.NoInsert])]
property MFKCTS: TDateTime read FMFKCTS write FMFKCTS;
[Column('MFK$LMTS', [TColumnProp.NoUpdate, TColumnProp.NoInsert])]
property MFKLMTS: TDateTime read FMFKLMTS write FMFKLMTS;
property LeadId: integer read FLeadId;
[Column('LEADSOURCE', [], 20)]
property LeadSource: nullable<string> read FLeadSource write FLeadSource;
[Column('LEADSOURCEID', [], 40)]
property LeadSourceId: nullable<string> read FLeadSourceId write FLeadSourceId;
[Column('FIRSTNAME', [], 20)]
property FirstName: nullable<string> read FFirstName write FFirstName;
[Column('LASTNAME', [], 20)]
property LastName: nullable<string> read FLastName write FLastName;
[Column('STREET', [], 40)]
property Street: nullable<string> read FStreet write FStreet;
[Column('CITY', [], 30)]
property City: nullable<string> read FCity write FCity;
[Column('STATE', [], 2)]
property State: nullable<string> read FState write FState;
[Column('ZIPCODE', [], 10)]
property ZipCode: nullable<string> read FZipCode write FZipCode;
[Column('HOMEPHONE', [], 20)]
property HomePhone: nullable<string> read FHomePhone write FHomePhone;
[Column('LEADAVAILABLE', [], 0)]
property LeadAvailable: byte read FLeadAvailable write FLeadAvailable;
[Column('LEADACCEPTEDBY', []), 0]
property LeadAcceptedBy: integer read FLeadAcceptedBy write FLeadAcceptedBy;
[Column('PRODUCT', [], 20)]
property Product: nullable<string> read FProduct write FProduct;
[Column('CAMPAIGNID', [])]
property CampaignId: integer read FCampaignId write FCampaignId;
[Column('UPLOADEDTOLEADMGMT', [], 0)]
property UploadedToLeadMgmt: byte read FUploadedToLeadMgmt write FUploadedToLeadMgmt;
[Column('MARKETINGID', [])]
property MarketingId: integer read FMarketingId write FMarketingId;
[Column('THEUNIQUEID', [], 20)]
property TheUniqueId: nullable<string> read FTheUniqueId write FTheUniqueId;
end;
My question was about the definition of the table in the database, not Aurelius. How does this Firebird table have an autogenerated id?
First of all you should remove the TColumnProp.NoInsert.
and you need to specify the name of the Sequence generator you want to use to generate an FLeadId (Must exist in the database since you use an existing database).
i.e.:
[Entity]
[Table('TBLLEADS')]
[Sequence('SEQ_LEAD_ID')]
[Id('FLEADID', TIdGenerator.IdentityOrSequence)]TLead = class
private
private
...
Thanks so much. That did the trick!