Print Page | Close Window

Where can I find info/documentation about "Adding API for composing dynamic queries" in the 5.2.2 release

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1458
Printed Date: 11-Mar-2025 at 4:13pm


Topic: Where can I find info/documentation about "Adding API for composing dynamic queries" in the 5.2.2 release
Posted By: pk55
Subject: Where can I find info/documentation about "Adding API for composing dynamic queries" in the 5.2.2 release
Date Posted: 08-Sep-2009 at 4:47pm
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)?
 
Thanks.



Replies:
Posted By: GregD
Date Posted: 09-Sep-2009 at 5:26pm
That description refers to the material described in the ../DevforceSilverlight/DevForceSilverlight_Documentation.aspx - release notes and ../DevforceSilverlight/DevForceSilverlight_Documentation.aspx - developers’ guide under… the following headings:

Ideablade.Linq.PredicateBuilder
Ideablade.Linq.PredicateDescription
 


Posted By: kimj
Date Posted: 09-Sep-2009 at 8:01pm
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);

 



Posted By: *Calsy
Date Posted: 28-Oct-2009 at 2:52pm
Hi People, Is there any way that we can build subqueries with the predicate builder. e.g.
var expr1 = new PredicateDescription(entityType, "Supplier.CompanyName", FilterOperator.Contains, "Blah");
 
Or is there a work around to do this?
 
Thanks


Posted By: kimj
Date Posted: 29-Oct-2009 at 6:36pm
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();


Posted By: *Calsy
Date 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.

Thanks



Print Page | Close Window