Trouble shoot a dynamic linq query in ASP.NET 4.0

dynamic-linq linq

Question

I have a regular linq query that is written as such:

    Clients.Where (c => c.EmailReturnUndeliverable == false || 
                        c.ClientBadStanding_TF == false)

I would like to dynamically write the query as such:

    Clients.Where ("EmailReturnUndeliverable = false Or ClientBadStanding_TF = false")

I have reviewed Scott G's article on Dynamic Linq and it looks like my syntax is correct.

However, I cannot get the 2nd query to run.

My setup:

VS 10 / ASP.NET App

Steps I have taken:

  • added the DynamicLibrary.cs file that Scott references into my 'App_Code' folder
  • attempted to use the Using statement: using System.Linq.Dynamic; (as used in Scott's 'DynamicLINQCSharp' project) but am getting a missing assembly reference error.

Anyone have any council on what I am missing or how to get the using statement to clear up?

1
2
2/23/2012 2:53:11 AM

Popular Answer

In case if your CLients is a list, can you try

 Clients.AsQueryable().Where ("EmailReturnUndeliverable = false Or ClientBadStanding_TF = false")

If I am not mistaken DynamicLibrary.cs has functions which can we applied to IQueryable

0
2/23/2012 5:11:15 AM


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