Hi,
I'm trying to add order by, in many value Associations in run time(Data Modeler does not export order by to aurelius). So far managed to add a field, but I need to add more than one field, here is the code:
class procedure TCheckStructure.AddOrderManyValuedAssociation(PMasterClassName: TClass; PMasterPropName: String; PDetailClassName: TClass; PDetailPropNames: String);
var
fAssociation: TAssociation;
fOrder: TOrderByInfo;
fExplorer: TMappingExplorer;
fPropNames: TStringList;
I: Integer;
begin
fExplorer:= TMappingExplorer.Default;
fAssociation := fExplorer.GetAssociationByPropertyName(PMasterClassName, PMasterPropName);
if fAssociation <> nil then
begin
fOrder := TOrderByInfo.Create;
fPropNames := TStringList.Create;
try
fPropNames.CommaText := PDetailPropNames;
for I := 0 to fPropNames.Count-1 do
begin
fOrder.Column := fExplorer.GetColumnByPropertyName(PDetailClassName, fPropNames.Strings);
fOrder.Direction := TOrderByDirection.Ascending;
fAssociation.OrderByList.Add(fOrder);// is this right?
end;
finally
fPropNames.Free;
end;
end;
end;
method call:
AddOrderManyValuedAssociation(TWktWkPn, 'WktPnDtList', TWktPnDt, 'Id, WktOrder');
this is the right approach?
thanks
Almost there,m you must create one TOrderByInfo object for each propname:
for I := 0 to fPropNames.Count-1 do
begin
begin
fOrder := TOrderByInfo.Create;
fOrder.Column := fExplorer.GetColumnByPropertyName(PDetailClassName, fPropNames.Strings);
fOrder.Direction := TOrderByDirection.Ascending;
fAssociation.OrderByList.Add(fOrder);// is this right?
end;
fOrder.Direction := TOrderByDirection.Ascending;
fAssociation.OrderByList.Add(fOrder);// is this right?
end;
Hi, wagner
Of course,
Thanks