Setup of the LINQ Dynamic Query Library

c# dynamic-linq linq

Question

In order to utilize dynamic where clauses, I am having problems putting up this Dynamic Linq Library. Please provide me some advice on how to properly reference and include this library to my project.

http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

shown in the post as well

Is there a pattern for dynamically generating filters using Linq?

thanks,

An update

var x = ListofObjects.AsQueryable().Where("Some comparison");

An update

My project won't compile after adding the Dynamic.cs library because of a number of compilation issues caused by that particular class. all comparable.

The namespace 'System.Linq.Dynamic' already contains a definition for 'DynamicOrdering' 
1
4
5/23/2017 10:08:34 AM

Accepted Answer

I feel that it works perfectly:

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);
    }
}
0
1/4/2012 2:07:45 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow