Predicate for EntityField2

Posts   
 
    
johnfattal
User
Posts: 6
Joined: 14-Feb-2007
# Posted on: 14-Feb-2007 17:33:33   

Not sure if I'm missing something here, but I can't seem to find a way to create a Predicate filter using an EntityField2 Object.

I need to be able to filter a collection based on a field in the collection, which is only known at runtime. Problem is that the Fields collection on an Entity returned using the adapter mode contains IEntityField2 objects, and I can only seem to find Predicates which take a IEntityField object.

Must be a way to do this, but how?!!? confused


EntityCollection<VehicleEntity> vehicles = new EntityCollection<VehicleEntity>();
            DataAccessAdapter adapter = new DataAccessAdapter();
            IRelationPredicateBucket bucket = new RelationPredicateBucket();

            adapter.FetchEntityCollection(vehicles, bucket);

            if(vehicles.Count > 0)
            {
                //Don't know at compile time what the Field name is. 
                IEntityField2 field = vehicles[0].Fields["Registration"];

                IPredicate filter = new FieldLikePredicate(field, "LG017BL");

                vehicles.FindMatches(filter);
            }

Many thanks in advance

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-Feb-2007 18:10:10   

Please refer to the LLBLGen Pro references manual for the FieldLikePredicate. You will find many overlods that accepts an IEntityFieldCore (which is implemented by EntityField2)