Different Views on the same situation

First i say thanks for your speedy answers in the past. I hope the questions are not to boring. Aurelius is really a fine pice of software.

Is it possible with aurelius to get to different views of the same data without replicating data.

For example :

A Invoice can be viewed from the Invoice itself, the Customer is then part of the Invoice :

TInvoice = class(TObject)
 FCustomer : TCustomer;

but it is also possible to understand the invoice as a Part of the Customer

TCustomer = class(TObject)
  FInvoices : TList<TInvoice>

How could i do a mapping which makes it possible to get both kind of views, without replicating the linked fields.

Is it enough if i declare the mapped fields by hand instead of automapping or should i do something else.


Hans Joerg Vasold

You can use declare both sides as you wrote in your own example. There is no problem with that. Note that when you do that, you must explicitly add the ManyValuedAssociation attribute and use the last parameter "MappedBy" indicating that the list is part of a bidirectional association:

[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll, 'FCustomer')]
FInvoices: Proxy<TList<Invoice>>;

for lists, it's always recommended to use proxies to perform lazy loading of the list.

Also note that this is for the model. If you just want to retrieve the list of invoices for a specified customer, you can simply do a query for that:

Invoices := Manager.Find<TInvoice>
  .CreateAlias('Customer', 'c')
  .Where(Linq['c.id'] = SomeCustomerIdValue)

Wagner R. Landgraf2016-11-04 22:45:43