Serialize TCreteriaResult

Hi
  How to serialize/deserialize TCreteriResult?
...
function TSMUserX.GetAllY: TObjectList<TCriteriaResult>;
begin
  Result := Manager.Find<TUserX>.Select(TProjections.ProjectionList
                                         .Add( TProjections.Prop('Id') )
                                         .Add( TProjections.Prop('UserName') )
                                        ).ListValues;
end;

function TSMUserX.GetAllY: TJSONValue;
var JSONToClient: TJSONVALUE;
      FSerializer: TDataSnapJsonSerializer;
begin
  FSerializer := TDataSnapJsonSerializer.Create;
  JSONToClient := GetAllY;
  try
    result := FSerializer.ToJson(JSONToClient);// How to????
  finally
    FSerializer .Free;
  end;
end;

and deserializer on client side? best approach.

thanks



For now you have to do it manually, unfortunately. The serializer/deseriailzer doesn't work directly with TCriteriaResult.

Hi, Wagner
  when we have a big table, many rows and many columns with associations , is to slow returning JSON to client (serialize and deserialize), some time we just need one field, something like "select name from customer". there is another way?
  thanks, Jofan
 

You can just manually serialize the criteria result using a Json library like DataSnap, SuperObject or even TMS Sparkle Json Writer. It should be just some lines of code to do so.

You can file a feature request for serializing TCriteriaResult though, it's a valid request we just have to order it in our priority list and if other people vote up for it it moves higher. 

Hi,
  When your  system grows  "... just some lines of code ..." becomes

hundreds lines of code. :). I added feature request. thanks Wagner

Hi, Wagner
  Excuse pursue this matter, but when you "manually serialize the criteria result using a Json library like DataSnap, SuperObject or even TMS Sparkle Json Writer", how to persist Fields on AureliusDataSet to bind with FMXGrid? or other data controls?
 Thank you very much

You create a TField for each property you have in your object that you want to be bound to a control. If you have a property "Name", create a TStringField with name "Name".

In Design time?
Thanks

Either design time or runtime