Returning a custom class

so far so good in testing xdata but i think i just face into a wall right here.
what i want to do here is something like this:

supose i have a TCustomer, TCustomerOrders class, they represent exactly what the name suggest and i want to have a server that basically process a report for example "customer order by year", so my logic here is to process the data from both entity and populate another class and return.

supose the return class would be like this:

  TCustomerOrderByYear = class
  public
    CustomerName : string;
    Year : Integer;
    Total : Extended;
  end;

but of course this is not allowed becouse i think xdata doesn't support this type of result, so the question is:

- there's a good explanation why this feature isn't provided? i mean, it would dramatically reduce the amount silly views of the database;
- there's a chance it will be provided in the near feature?
- there's a turnout for this problem?

TCustomerOrderByYear class must be an Aurelius entity, then you can return it from XData methods. Read about the multi-model system, that's why it was introduced. You can have several different models with different classes defined for it. You just need to add the classes you need.

Maybe i didn't understand the part that the class TCustomerOrderByYear must be tagged with the [Entity] attribute, as far as my understand goes this means that the class is a entity (table) that in fact exists in the database, with is not the case.


I edited my class to this:

  [Model('global')]
  [Entity]
  TCustomerOrderByYear = class
  public
    [Transient]
    CustomerName : string;

    [Transient]
    Year : Integer;

    [Transient]
    Total : Extended;
  end;

after i register the class with RegisterEntity(TCustomerOrderByYear) i get this error:

"Cannot find mapping [Id] on class TCustomerOrderByYear"

So maybe i wasn't clear in my question what im trying to return from the service is a custom class that only exists in delphi application, it is not a view nor a entity in my database.

The entity must be mapped so Aureilus/XData knows how to serialize it (according to the mapped fields).

By using [Model] attribute you can separate the class in models so you don't need to have it in a database. And since it's an entity, then you must define an [Id] for it.