typed IPredicate

Posts   
 
    
zivtir
User
Posts: 17
Joined: 10-Jun-2010
# Posted on: 07-Sep-2010 12:53:12   

Hi i m using this code:

internal void RunUpdatePredicateExpression(EntityBase2 entityToUpdate, IPredicate[] predicates) { IRelationPredicateBucket filter = new RelationPredicateBucket(); foreach (var item in predicates) { filter.PredicateExpression.AddWithAnd(item); } using (IDataAccessAdapter adapter = this.DataAccessAdapterProvider.GetAdapter()) { adapter.UpdateEntitiesDirectly(entityToUpdate, filter); } } now i want that the IPredicate be for specific entity on the declaration of the function. it prevent runtime error when i try to add Predicates which are not match the entityToUpdate. how can i manage it? thanks

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 07-Sep-2010 20:56:59   

Is there a particular reason why you need this generic a routine, and how would you get to a situation where it ends up being passed predicates that don't match the entities - surely whoever is calling this routine know what they are passing...?

Matt

zivtir
User
Posts: 17
Joined: 10-Jun-2010
# Posted on: 12-Sep-2010 09:31:27   

that what I want to prevent on compile time that to the routine only get predicate that belongs to the specific entity type.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Sep-2010 04:18:03   

I think that is not possible, at lest I see that very complex. You see, a predicate can be very simple or very complex (expressions, expression into another, DBFunctionCalls, etc). So you can't just change the involved entity of a predicate.

In my opinion, this should be managed outside, I mean, the programmer should know that he can't pass a predicate that doesn't match some entity type.

David Elizondo | LLBLGen Support Team