Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tom Saddul
  Where is Tom Saddul?
 Tom Saddul
 To: Mani kandan
  Where is Mani kandan?
 Mani kandan
Subject: RE: Dynamic Where Condition in LINQ
Thread ID: 373672 Message ID: 373675 # Views: 45 # Ratings: 0
Version: Not Applicable Category: VFP and .NET
Date: Monday, March 25, 2013 9:13:42 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

It depends on your source data. If it is a List, you can have it like this:

List<WhatEverType> list = new List<WhatEverType>();  // Source data

List<WhatEverType> filtered = list.Where((e) => e.Field == "the value here");  // filtered will contain the filtered list

A predicate is simply a Func<type1, type2, ..., returnType> delegate declaration. In the example above, I used a lambda expression for the predicate which is:

(e) => e.Field == "the value here"


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