mario.muja wrote:
though if component and specialcomponent have a 1:1 relation
What if the relation type is 1:n?
Then you can create a field mapped on a related field in the entity with the opposite relation. So: Customer 1:n Order. Then in Order, you have a m:1 relation with Customer, and you can create a field mapped onto a field in Customer.
, you can create Fields mapped on related fields in specialcomponent, which are mapped on fields in component. Witha prefetch path you can fetch them together.
Can you please show me some example code?
Would I receive a specialcomponent object with all the attributes aggregated for the 1:1 relation?
If 2 entities have a 1:1 relation, and you create a couple of fields mapped onto related fields in one of them (which thus map on fields in the related entity), you just have to fetch the two entities together, using a prefetch path.
So instead of doing:
adapter.FetchEntity(orderEntity);
you specify a prefetch path which also fetches the customer:
IPrefetchPath2 path = new PrefetchPath2((int)EntityType.OrderEntity);
path.Add(OrderEntity.PrefetchPathCustomer);
adapter.FetchEntity(orderEntity, path);
(or if you're using selfservicing
We plan to use the adapter approach, because we have to serve more than one database product.
Saves have to be done recursively.
Is this done automatically or would I have to code the recursion manually?
Saves are recursive by default in Adapter. You can manually specify if you don't want that, by using an overload of SaveEntity()