I am having trouble setting up this Dynamic Linq Library so i can use Dynamic where clauses. Can someone advise me onhow to add this library to my project and reference correctly.
also seen in the post
Is there a pattern using Linq to dynamically create a filter?
thanks,
Update -
var x = ListofObjects.AsQueryable().Where("Some comparison");
Update -
After adding the Dynamic.cs library my project wont build with a bunch of compilation errors coming from that specific class. all similar to.
The namespace 'System.Linq.Dynamic' already contains a definition for 'DynamicOrdering'
Seems to work fine for me:
public class SomeType
{
public string var1;
public string var2;
}
class Program
{
static void Main(string[] args)
{
var myList = new List<SomeType>();
myList.Add(new SomeType() { var1 = "abc", var2 = "abc" });
myList.Add(new SomeType() { var1 = "def", var2 = "def" });
foreach (var item in myList.AsQueryable().Where("var1=\"abc\""))
Console.WriteLine("item.var1 = " + item.var1);
}
}