Entity Mapping
Posted: Wed 08 Jun 2016 13:28
Hi,
I've been following the documentaiton found in the https://www.devart.com/entitydac/docs/? ... xpress.htm and making a framework for my company internal usage.
Basically, i have to create entity throught out code. But my mapping end up with runtime error and i'm clueless why. It only happens when an entity has more than one reference or collection.
this one is ok
However, when i add another reference it gives me a Runtime error 217 .....
Any help is appreciated
I got the solution,
i was mistaking the reference ID, plus it is case sensitive.
I've been following the documentaiton found in the https://www.devart.com/entitydac/docs/? ... xpress.htm and making a framework for my company internal usage.
Basically, i have to create entity throught out code. But my mapping end up with runtime error and i'm clueless why. It only happens when an entity has more than one reference or collection.
this one is ok
Code: Select all
[Table('enum')]
[Model('DataModel')]
[Key('Fenumid')]
TCAFEnum = class(TMappedEntity)
private
[Column('enumid', [ReadOnly])]
Fenumid: Integer;
[Column]
[Collection('TCAFEnumItem', 'FCAFEnum', 'Fenumitemid', 'Fenumitemid', srNone, drNone)]
FCAFEnumItemCollection: TCollectionData;
...
end;
[Table('enumitem')]
[Model('DataModel')]
[Key('Fenumitemid')]
TCAFEnumItem = class(TMappedEntity)
private
[Column('enumitemid', [ReadOnly])]
Fenumitemid: Integer;
[Column('enumid', [CanBeNull])]
Fenumid: IntegerNullable;
[Column]
[Reference('TCAFEnum','FCAFEnumItemCollection','Fenumid','Fenumid', srNone,drNone)]
FCAFEnum: TReferenceData;
...
end;
Code: Select all
[Table('project')]
[Model('DataModel')]
[Key('Fprojectid')]
TCAFProject = class(TMappedEntity)
private
[Column('projectid', [ReadOnly])]
Fprojectid: Integer;
[Column]
[Collection('TCAFEnum', 'FCAFProject', 'Fprojectid', 'Fprojectid', srNone, drNone)]
FCAFEnumCollection: TCollectionData;
...
end;
[Table('enum')]
[Model('DataModel')]
[Key('Fenumid')]
TCAFEnum = class(TMappedEntity)
private
[Column('enumid', [ReadOnly])]
Fenumid: Integer;
[Column]
[Reference('TCAFProject', 'FCAFEnumCollection', 'Fprojectid', 'Fprojectid', srNone, drNone)]
FCAFProject: TReferenceData;
[Column]
[Collection('TCAFEnumItem', 'FCAFEnum', 'Fenumitemid', 'Fenumitemid', srNone, drNone)]
FCAFEnumItemCollection: TCollectionData;
...
end;
[Table('enumitem')]
[Model('DataModel')]
[Key('Fenumitemid')]
TCAFEnumItem = class(TMappedEntity)
private
[Column('enumitemid', [ReadOnly])]
Fenumitemid: Integer;
[Column('enumid', [CanBeNull])]
Fenumid: IntegerNullable;
[Column]
[Reference('TCAFEnum','FCAFEnumItemCollection','Fenumid','Fenumid', srNone,drNone)]
FCAFEnum: TReferenceData;
...
end;
I got the solution,
i was mistaking the reference ID, plus it is case sensitive.