phil.salomon wrote:
I have a method which takes a list of fields from one table with values. I just want to retrieve a list of rows which match the fields/values.
How that list looks like? The best option is that you pass IEntityField2 objects.
Example:
public EntityCollection<CustomerEntity> SearchInCustomers(List<IEntityField2> fields, List<object> values)
{
// build the filter
IRelationPredicateBucket filter = new RelationPredicateBucket();
for (int i=0; i< fields.Count; i++)
{
filter.PredicateExpression.Add(fields[i] == values[i]);
}
// fetch
EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>();
using (var adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(customer, filter);
}
// return results
return customer
}
... and to use it:
IList<IEntityField2> theFields = new List<IEntityField2>();
IList theValues = new List();
theFields.Add(CustomerFields.CustomerId);
theValues.Add("ALFKI");
theField.Add(CustomerFields.Country);
theValues.Add("Guatemala");
// search
EntityCollection<CustomerEntity> matches = SearchInCustomers(theFields, theValues);
To know more about the predicate system and what else you can achieve, please read this.