Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends,I'm interested in MVC I have one small Doubt.
I want to know how to generate dynamic queries for example.
If i want to retrive items <1500 then i write a query expression for that .now if i like to make more suggestions like size>8 and brand=='Reebok' delivery=2days then what i have to do.should i write query for all the chances.there will number of ways the user can ask query how to answer them dynamically.i heard about expression tress but.
Plz post any answers and real time usage of it.
Thanks.
Posted

1 solution

Hi,

what you asking is very simple.

IQueryable is the type which will help you to do the same.

In depth details of IQueryable : http://blogs.msdn.com/b/mattwar/archive/2007/07/30/linq-building-an-iqueryable-provider-part-i.aspx[^]

In sort IQueryable will execute the query when you call (ToList,ToArray etc) till that time it will just build the query so you can manipulate the same.

Predicates Builder : http://www.albahari.com/nutshell/predicatebuilder.aspx[^]

It will serve your purpose :Dynamic Querying with LINQ-to-Entities and Expressions[^]
 
Share this answer
 

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