Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Talk to Webmaster Tony John
Online Members
Pawan Awasthi
Saranya
More...
Forums
»
.NET
»
LINQ
»
Dynamic Query creation in Linq.
Posted Date:
08 Apr 2010
Posted By::
Kunal
Member Level:
Bronze
Member Rank:
0
Points
: 1
Responses:
1
i am using .net freamwork 3.5
i want to find data from sqlserver database.
i want to do it useing dynamic linq.
is it possible? if yes then how?
Tweet
Responses
#491680 Author:
Tejas Trivedi
Member Level:
Gold
Member Rank:
136
Date: 08/Apr/2010 Rating:
Points
: 2
Hi,
yes, it is possible to have dynamic query while using linq to sql.
The Dynamic Expression API provides IQueryable Extension Methods as part of System.Linq.Dynamic.DynamicQueryable class for dynamically querying objects.
We can construct the above query using the IQueryable extension method Where() like below:
DataClassesDataContext db=new DataClassesDataContext();
var products = db.Products
.Where("Model==@0 && onsale==@1","SD1000", true) ;
also, it is possible to make whole condition string dynamically.
DataClassesDataContext db=new DataClassesDataContext();
string condition = "Model==\"SD1000\" && onsale==true ";
var products = db.Products.Where(condition );
Thanks.
Regards,
Tejas
Thanks & Regards
Tejas
[Don't just write Softwares,Write an innovative solutions.]
Post Reply
This thread is locked for new responses. Please post your comments and questions as a
separate thread
.
If required, refer to the URL of this page in your
new post
.
Tweet
Next :
Readind data from XML and copying to an array or object
Previous :
Avoid Looping
Return to Discussion Forum
Post New Message
Category:
Related Messages
Binding with repeater
From where to start? what is it LinQ?
Readind data from XML and copying to an array or object
Follow us on Twitter:
https://twitter.com/dotnetspider
Active Members
Today
Pawan Awasthi
(42)
srirama
(7)
Phagu Mahato
(7)
Last 7 Days
baskar
(298)
Asheej T K
(173)
Ultimaterengan
(167)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds