Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to write a query with lINQ that a part of it should be filled dynamically! I searched on the internet but what i have found is not what I really wanted. I mean I want something like this:

from c in table where X==Y select Z

and here all X, Y and Z are variables and their values can be get dynamically.

What I found on the internet was something like this:

from c in table where property=X select sth

in that query just X is variable, but what I want is that a part of the query to be built dynamically.

How can I do that (in old style (SQL) you could write the query by combining some strings but here you can not do that)

Thanks a lot in advance!
Posted

1 solution

Hi
we can use Expression trees for building dynamic LINQ queries

http://msdn.microsoft.com/en-us/library/bb882637.aspx


http://tomasp.net/blog/dynamic-linq-queries.aspx



Thanks
Radhakrishnan G.

 
Share this answer
 
v5
Comments
Nish Nishant 3-Nov-10 10:31am    
Radha, your links are broken (the text is right, but the html points to an invalid url).
Nish Nishant 3-Nov-10 10:31am    
It's because your html has this

href=""

for both the links.
Radhakrishnan G. 3-Nov-10 10:35am    
Updated

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