Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Say we have :
C#
public class someclass
{
   public string name;
   public int age;
}

List<someclass> data = new List<someclass>();

How can we query the above using a string predicate like below given that it can be done with LINQ predicates:
C#
var q = data.FilterMethod("age<20 and name = \"bob\" ");
Posted

1 solution

You can use aggregate grouped LInQ operators like:

C#
List<someclass> data = new List<someclass>();

var resultSet =
    from p in data
    group p by p.name into g
    select new { Name = g.Key, Age < 20 };</pre>
 
Share this answer
 
Comments
Mehdi Gholam 24-Jun-12 2:38am    
I need it to be a string, sorry.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900