Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Cetin Basoz
 To: Mani kandan
  Where is Mani kandan?
 Mani kandan
Subject: RE: Dynamic Where Condition in LINQ
Thread ID: 373672 Message ID: 373681 # Views: 48 # Ratings: 0
Version: Not Applicable Category: VFP and .NET
Date: Monday, March 25, 2013 9:48:51 AM         

> Hi
> I want to runt the linq query with dynamic filter.
> lcConditn = "Field = "+value1
> For example: In our VFP we can give locate for &lcConditn.
> same this i want to use in linq query in C#. i searched in net. those saying predicatebuilder class. im not aware of that.
> please help me to do this.
> Advance thanks
> Manikandan.s

With Linq the query gets enumerated when something executes it (ie: foreach, binding to a source etc). That means you can attach a where clause when you need it where you need it. IOW it is straight forward to add the where and you don't need something like a macro substitution. ie:

var customers = from c in db.Customers select c;

// where you need to a have a where
var country = "USA";
var customersInSpecificCountry = customers.Where( c => c.Country == country );

Of course PredicateBuilder have some cool advantages, you can get it from here:


and it is also part of LinqKit:


Cetin Basoz

.Net has got better.Think about moving - check my blog:
My Blog

MongoDb Certified Developer
MongoDb Certified DBA

Support Wikipedia


Dynamic Where Condition in LINQ Posted by Mani kandan @ 3/25/2013 8:06:45 AM
RE: Dynamic Where Condition in LINQ Posted by Tom Saddul @ 3/25/2013 9:13:42 AM
RE: Dynamic Where Condition in LINQ Posted by Cetin Basoz @ 3/25/2013 9:48:51 AM