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?!!?
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