UpdateEntitiesDirectly - Tree of tables

Posts   
 
    
Dimitris
User
Posts: 2
Joined: 23-Feb-2015
# Posted on: 23-Feb-2015 10:33:46   

Hi

I am using llblgen v 4.1.0.0 I have a question regarding the “UpdateEntitiesDirectly” method of the adapter. I want to update a tree of 3 tables. For example: 1. The first table is the Clients table with primary key IdClient 2. The second table is the Orders table with primary key IdClient and IdOrders 3. And finally the third table is the OrdersList table with primary key IdOrders and IdOrdersList

For the first table I can use the following in order to update the table directly

var bucket = new RelationPredicateBucket(ClientsFields.IdClient == 1);
..
adapter.UpdateEntitiesDirectly(clientEntity, bucket);

For the second table I can also use a similar approach

var bucket = new RelationPredicateBucket(OrdersFields.IdClient == 1);
..
adapter.UpdateEntitiesDirectly(orderEntity, bucket);

My question is how can I update directly the third table (OrdersList) without fetching all the IdOrders? Is there a way to create a relationship in the RelationPredicateBucket between the Orders table and the OrdersList table so I can directly update the OrdersList table?

Regards Dimitris

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 24-Feb-2015 07:59:31   

Hi Dimitris,

Yes, you can. In this case the best option is to use a FieldCompareSetPredicate in your filter:

bucket.PredicateExpression.Add(new FieldCompareSetPredicate(
    OrderListFields.IdOrder, null, OrderFields.IdOrder, null,
    SetOperator.In, (OrderFields.IdClient == 1)));

adapter.UpdateEntitiesDirectly(orderEntity, bucket);
David Elizondo | LLBLGen Support Team
Dimitris
User
Posts: 2
Joined: 23-Feb-2015
# Posted on: 24-Feb-2015 14:19:19   

Hi David

Thank you very much for your reply. The solution that you proposed worked but with a minor change. Initially, when I tried to implement the solution that you proposed, I got the error "the multipart identifier ... can be found". So instead of adding to the previous RelationPredicateBucket, I created a new bucket and everything worked as expected.

Thank you very much for the support Dimitris

daelmo wrote:

Hi Dimitris,

Yes, you can. In this case the best option is to use a FieldCompareSetPredicate in your filter:

bucket.PredicateExpression.Add(new FieldCompareSetPredicate(
    OrderListFields.IdOrder, null, OrderFields.IdOrder, null,
    SetOperator.In, (OrderFields.IdClient == 1)));

adapter.UpdateEntitiesDirectly(orderEntity, bucket);