I'm trying to Insert ManyValuedAssociation,
[Entity]
[Table('Wkt')]
[Inheritance(TInheritanceStrategy.JoinedTables)]
[Sequence('Id_Wkt')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TWkt = class
private
[Column('Id', [TColumnProp.Required])]
FId: Int64;
[ManyValuedAssociation([TAssociationProp.Lazy, TAssociationProp.Required], [TCascadeType.SaveUpdate, TCascadeType.Merge], 'FWktId')]
FWktWStList: Proxy<TList<TWktWSt>>;
function GetWktWStList: TList<TWktWSt>;
public
constructor Create;
destructor Destroy; override;
property Id: Int64 read FId write FId;
property WktWStList: TList<TWktWSt> read GetWktWStList;
end;
[Entity]
[Table('WktWSt')]
[PrimaryJoinColumn('Id')]
TWktWSt = class(TWktSet)
private
[Association([TAssociationProp.Lazy, TAssociationProp.Required], CascadeTypeAll - [TCascadeType.Remove])]
[JoinColumn('WktId', [TColumnProp.Required], 'Id')]
FWktId: Proxy<TWkt>;
function GetWktId: TWkt;
procedure SetWktId(const Value: TWkt);
public
property WktId: TWkt read GetWktId write SetWktId;
end;
[Entity]
[Table('WktSet')]
[Inheritance(TInheritanceStrategy.JoinedTables)]
[Sequence('Id_WktSet')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TWktSet = class
private
[Column('Id', [TColumnProp.Required])]
FId: Int64;
[Column('SetNumber', [TColumnProp.Required])]
FSetNumber: integer;
public
property Id: Int64 read FId write FId;
property SetNumber: integer read FSetNumber write FSetNumber;
end;
Manager.Merge(TWkt(NewDBObject));
'[FireDAC][Phys][FB]validation error for column WKTID, value "*** null ***"'.
How to save TWkt object? when TWkt already exist(update) merge is ok.
thanks, Jofan
I have no idea what is and what contains NewDBObject, but the error says WKTID field is null, so you must fill it:
Hi,
Yes, that's it, (sorry malformed JSON).
I'm try to delete a line in a master-detail, using REST/JSON.
How to delete a item on the detail(TWktWSt)?
Ex: TWkt have 3 itmes on WktWStList, i need to delete item 2. If i merge TWkt without item 2, aurelius delete the item 2?
Yes, it does that if you use Merge.
Note that "delete" means just removing the item from the list. If you want to really delete, you must set TCascadeType.RemoveOrphan on that ManyValuedAssociation, or just delete the item directly which will obviously remove it from the list eventually.
Hi
TCascadeType.RemoveOrphan, sorry, but where is that on DataModeler?
thanks
There is no such option in Data Modeler, you have to add it manually.
Hi,
thanks
Hi,
is it possible to add TCascadeType.RemoveOrphan in run time? I think its not possible add an attribute to field in runtime,but there is some Published directive?
thanks, thanks, thanks
Hi,
Thanks Wagner works like a charm.
Thanks Hilanne, if you need something like that you should try Wagner suggestion.
Yes,Thanks. That's useful information to do some after export tailoring in the code.