How to build Dynamic Linq from Request.QueryString?

asp.net-mvc dynamic-linq linq

Question

I'm presently developing a feature that uses Request.QueryString to create or build a filter. The concept is that the filter may be applied to any model property. For ex.,

public class Alert{
    public string Name;
    public string Status;
    public Datetime StartDate;
    public Datetime EndDate;
    public bool IsActive;
}

The calling client thus wants to send something along in the query string.startdate >=2013-10-1&Name=John&IsActive=false . I'm building the where clause, which accepts a string, using System.Linq.Dynamic from Scottgu, but the format is sort of killing me. I'm performing the type checking using reflection before running this, and I'm also filtering this against the data that came back from the Database and not feeding this into the db. I need some ideas on the format. We much appreciate any assistance.

1
0
11/17/2013 5:02:39 PM

Popular Answer

Avoid creating a new wheel if you don't have to.

Consider Odata and the.net web.api

That ought to fulfill your needs.

0
10/21/2013 8:00:05 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