Lazy loading with constraints

Posts   
 
    
shennig
User
Posts: 48
Joined: 14-Nov-2006
# Posted on: 13-Feb-2007 17:37:45   

Hi.

is it possible to load referenced objects with constraints, not using prefetched paths but loading on demand (lazy loading)? (thats only for selfservicing, that i know)

say you have loaded a customer entity and now you want to load all corresponding orders, but only those with a total sum from over 100 € or so.

normally if you do that:


orderentitycollection oOrders = costumer.order;

you get all orders, if you have not used prefetched path with the filter on order.total > 100. how can i get only those order objects which fullfill the constraint in a lazy manner?

thanks,

shennig

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 14-Feb-2007 02:11:33   

You can do something like this.


IPredicateExpression filter = new PredicateExpression();
filter.Add(OrderFields.Total > 100);
OrderCollection orders = customer.GetMultiOrder(true, filter);
shennig
User
Posts: 48
Joined: 14-Nov-2006
# Posted on: 14-Feb-2007 08:19:21   

Great! That's what i have searched for!

Thanks a lot!