New Posts New Posts RSS Feed: Predicate Builder Example
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Predicate Builder Example

 Post Reply Post Reply
Author
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Topic: Predicate Builder Example
    Posted: 16-Feb-2011 at 11:52am

Hi Markus,

Did you try executing your snippet? It won't retrieve any results. (You should be using x.ProductName.Contains(..) )
 
As for where the query gets executed, if it's running against the datasource, it will be executed on the server; if it's against the cache, the execution is in the client.
If you haven't explicitly set QueryStrategy, execution will depend on whether it has been executed previously (and therefore in the QueryCache, which will trigger a cache query) or not.
 
You can find more information on QueryStrategy and QueryCache in our DevForce Resource Center.
 
Regards,
   Silvio.


Edited by sbelini - 16-Feb-2011 at 12:01pm
Back to Top
mseeli View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Sep-2010
Location: Switzerland
Posts: 31
Post Options Post Options   Quote mseeli Quote  Post ReplyReply Direct Link To This Post Posted: 04-Feb-2011 at 12:30am
I have a question regarding your example in the documentation about using the Predicate Builder:
finding all Products with either of “Sir Cajun Louisiana”

I would solve the problem as follows

  var _products = new ObservableCollection<Product>();
  var db = NorthwindIBEntities.DefaultManager;
  var li = new List<string>();

  li.Add("Sir");
  li.Add("Cajun");
  li.Add("Louisiana");

  db.GetQuery<Product>().Where(x => li.Contains(x.ProductName)).ExecuteAsync(op => 
            {foreach (var p in op.Results) _products.Add(p);} );

I understand that predicates can do a lot more than what is required in this simple example. 
My question is if there are important reasons not to solve this example in my way.
Where does this query get executed (on the server or the client)?

Markus Seeli 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down