New Posts New Posts RSS Feed: Where can I find info/documentation about "Adding API for composing dynamic queries" in the 5.2.2 release
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

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

 Post Reply Post Reply
Author
pk55 View Drop Down
Senior Member
Senior Member


Joined: 22-Jul-2009
Location: CA
Posts: 105
Post Options Post Options   Quote pk55 Quote  Post ReplyReply Direct Link To This Post Topic: Where can I find info/documentation about "Adding API for composing dynamic queries" in the 5.2.2 release
    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.
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 09-Sep-2009 at 5:26pm
That description refers to the material described in the release notes and developers’ guide under… the following headings:

Ideablade.Linq.PredicateBuilder
Ideablade.Linq.PredicateDescription
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post 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);

 

Back to Top
*Calsy View Drop Down
Groupie
Groupie


Joined: 02-Feb-2009
Location: Australia
Posts: 69
Post Options Post Options   Quote *Calsy Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post 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();
Back to Top
*Calsy View Drop Down
Groupie
Groupie


Joined: 02-Feb-2009
Location: Australia
Posts: 69
Post Options Post Options   Quote *Calsy Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down