QuoteReplyTopic: Where can I find info/documentation about "Adding API for composing dynamic queries" in the 5.2.2 release Posted: 30-Oct-2009 at 12:15am
Yeah for the situation I want to use it in I need to provide the nested query property as a string i.e. "Supplier.CompanyName". This is so we can dynamically build up our filter.
Unfortunately the PredicateDescription does currently have the limitation that the property exist on the supplied type, but we'll open a bug report for this since it should be possible to query for nested properties.
The workaround right now would be to use the Expression<Func<T, bool>> syntax of the PredicateBuilder, which may not quite meet your needs ...
Expression<Func<Product, bool>> crit1 = p => p.Supplier.CompanyName.Contains("Blah"); var query = entityManager.Products.Where(crit1); var list = query.ToList();
You can aslo dynamically create an EntityQuery<T>, where T isn't known until run time. Here's a sample -
var entityType = typeof(Product);
var baseQuery = (IQueryable) TypeFns.ConstructGenericInstance(typeof(EntityQuery<>), entityType);
var expr1 = new PredicateDescription(entityType, "UnitPrice", FilterOperator.IsGreaterThanOrEqualTo, 24); var expr2 = new PredicateDescription(entityType, "Discontinued", FilterOperator.IsEqualTo, true);
var query = PredicateBuilder.FilterQuery(baseQuery, expr1.And(expr2));
var results = _entityManager.ExecuteQuery((IEntityQuery)query);
I've looked through the release notes as well as the reference help and the developers guide but didn't see any mention of one of the new features mentioned in the forum post that announced the new release; Adding API for composing dynamic queries.
Was this referring to the PredicateDescription and building dynamic filters (I was hoping for dynamic queries where the type could also be specified in the same way you're specifying the field as a string in the PredicateDescription)?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum