TCustomCriterion to Json no Value

Hi,

On the client-side I create a Transfer class with a list of TCustomCriterion.
I serialize the class to send it to the server (datasnap)

But the value is not serialized of the TCustomCriterion.


Client code:

 oTransfer.AddCustomCriterion((Linq['Name'].Like('MARC')));

Json:

'{"clazzName":"Entities.Customer.TCustomer","connectionString":"TestDB",
"fetchEagerAliasList":{"ownsObjects":true,"listHelper":[1],"items":[{"associationPath":"CustomerToAddress"}]},
"customCriterionList":{"ownsObjects":true,"listHelper":[1],"items":[{"projection":{"propName":"Name"},"oper":"Like"}]}}'

I can't see the value 'MARC' in Json, Why?

Regards,
Christophe Ravaut

That's up to the DataSnap serializer. Does it serialize Variant values?

I use the TJSON.ObjectToJsonObject

Maybe DataSnap doesn't serialize Variant values. I can't be sure, it's on DataSnap side. Aurelius doesn't have a direct serializer for TCustomCriterion object.

Ok, I see that TJSON.ObjectToJsonObject doesn't serialize variant.

Any suggestion for serialize the variant?

I'm not sure how to it with the DataSnap serialization. Maybe you should just try to create your own DTO class to send the criteria? I'm not sure it's safe to serialize such low-level framework classes like TCustomCriterion directly. 

Yep, I've create my own class TCriterion. And add the list to the TCriteria on the server-side.

  for oCriterion in self.CriterionList do
  begin
    case oCriterion.OperatorKind of
      oprIs: oCriteria.Add(Linq.Eq(oCriterion.Name, oCriterion.Value));
      oprLike: oCriteria.Add(Linq.Like(oCriterion.Name, oCriterion.Value));
    end;
  end;