Hi,
I Have A Class TCustomer with property CustomerToAddress
typeI want that the associactions CustomerToAddress is loaded, so I use this code:
[Entity]
[Table('CUSTOMERS')]
TCustomer = class (TBaseWithID)
private
[Column('FIRSTNAME')]
FFirstName: String;
[Column('NAME')]
FName: String;
[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll)]
[ForeignJoinColumn('CUSTOMERID', [TColumnProp.Required])]
FCustomerToAddress: Proxy<TList<TCustomerToAddress>>;
[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll)]
[ForeignJoinColumn('CUSTOMERID', [TColumnProp.Required])]
FCustomerToAddress1: Proxy<TList<TCustomerToAddress1>>;
[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll)]
[ForeignJoinColumn('CUSTOMERID', [TColumnProp.Required])]
FCustomerToAddress3: Proxy<TList<TCustomerToAddress3>>;
procedure SetFirstName(const Value: String);
procedure SetName(const Value: String);
function GetCustomerToAddress: TList<TCustomerToAddress>;
function GetCustomerToAddress1: TList<TCustomerToAddress1>;
function GetCustomerToAddress3: TList<TCustomerToAddress3>;
public
property FirstName: String read FFirstName write SetFirstName;
property Name: String read FName write SetName;
property CustomerToAddress: TList<TCustomerToAddress> read GetCustomerToAddress;
property CustomerToAddress1: TList<TCustomerToAddress1> read GetCustomerToAddress1;
property CustomerToAddress3: TList<TCustomerToAddress3> read GetCustomerToAddress3;
end;
oCustomers:= Mng.Find<TCustomer>But when I convert it to a Json the CustomerToAddress is not loaded.
.CreateAlias('CustomerToAddress', 'cta', TFetchMode.Eager)
.Where(Linq.Like('Name', 'MARC'))
.List;
Json:
'[{"$type":"Entities.Customer.TCustomer","$id":1,"FID":1772,"FFirstName":"","FName":"Marc",
"FCustomerToAddress":{"$proxy":"list","key":1772,"class":"TCustomer","member":"FCustomerToAddress"},
"FCustomerToAddress1":{"$proxy":"list","key":1772,"class":"TCustomer","member":"FCustomerToAddress1"},
"FCustomerToAddress3":{"$proxy":"list","key":1772,"class":"TCustomer","member":"FCustomerToAddress3"}}]'
I think that the CustomerToAddress is not loaded, because when I to oCustomers.First.CustomerToAddress and then an conversion to Json then I get
'[{"$type":"Entities.Customer.TCustomer","$id":1,"FID":1772,"FFirstName":"","FName":"Marc",Any Idee?
"FCustomerToAddress":[{"$type":"Entities.CustomerToAddress.TCustomerToAddress1","$id":2,"FCustomerID":1772,"FAddressID":2228,"FAddressTypeID":1,"FAddress":{"$proxy":"single","key":2228,"class":"TCustomerToAddress","member":"FAddress"}}],
"FCustomerToAddress1":{"$proxy":"list","key":1772,"class":"TCustomer","member":"FCustomerToAddress1"},
"FCustomerToAddress3":{"$proxy":"list","key":1772,"class":"TCustomer","member":"FCustomerToAddress3"}}]'
I gone a set the logger to see if the sqlquery is correct.