I have an association set up where the associated entity may be linked to a number of entities. The main entity, an event is assigned to a location. The location can be associated to multiple entities - the link is on locationid. What I want to be able to do is to change the locationid on a event (e.g., switch it's location), but when I change the locationid, instead of just changing the locationid on the event, it tries to change the locationid in the location table that the event was linked to.
For example, event A is linked to locationid 100. I want to change the locationid to 200. When I make this change, it tries to change the master locationid to 200, instead of just changing the events locationid. The generated entity does not directly expose the locationid, so you need to update it via the attached Tlocation.locationid. I think this is what is causing the problem. I can remove the association and update the locationid on the event record and just add the locationid field, but I want to be able to include the location data.
Thanks.
type
TEvent = class;
TLocation = class;
[Entity]
[Table('Events')]
[Id('FEventid', TIdGenerator.IdentityOrSequence)]
TEvent = class
private
[Column('EventID', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FEventid: Int64;
[Column('EventName', [TColumnProp.Required], 150)]
FEventname: string;
[Association([], CascadeTypeAll - [TCascadeType.Remove])]
[JoinColumn('LocationID', [], 'LocationID')]
FLocationid: TLocation;
public
property Eventid: Int64 read FEventid write FEventid;
property Eventname: string read FEventname write FEventname;
property Locationid: TLocation read FLocationid write FLocationid;
end;
[Entity]
[Table('Locations')]
[Id('FLocationid', TIdGenerator.IdentityOrSequence)]
TLocation = class
private
[Column('LocationID', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FLocationid: Int64;
[Column('LocationName', [], 150)]
FLocationname: Nullable<string>;
[Column('Address1', [], 100)]
FAddress1: Nullable<string>;
[Column('Address2', [], 100)]
FAddress2: Nullable<string>;
[Column('Address3', [], 100)]
FAddress3: Nullable<string>;
[Column('City', [], 100)]
FCity: Nullable<string>;
[Column('StateCD', [], 10)]
FStatecd: Nullable<string>;
[Column('Region', [], 100)]
FRegion: Nullable<string>;
[Column('PostalCD', [], 20)]
FPostalcd: Nullable<string>;
[Column('CountryCD', [], 5)]
FCountrycd: Nullable<string>;
[Column('LocationPhone', [], 50)]
FLocationphone: Nullable<string>;
[Column('URLWWW', [], 250)]
FUrlwww: Nullable<string>;
public
property Locationid: Int64 read FLocationid write FLocationid;
property Locationname: Nullable read FLocationname write FLocationname;
property Address1: Nullable read FAddress1 write FAddress1;
property Address2: Nullable read FAddress2 write FAddress2;
property Address3: Nullable read FAddress3 write FAddress3;
property City: Nullable read FCity write FCity;
property Statecd: Nullable read FStatecd write FStatecd;
property Region: Nullable read FRegion write FRegion;
property Postalcd: Nullable read FPostalcd write FPostalcd;
property Countrycd: Nullable read FCountrycd write FCountrycd;
property Locationphone: Nullable read FLocationphone write FLocationphone;
property Urlwww: Nullable read FUrlwww write FUrlwww;
end;