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
s
Pritom Nandy
More...
Forums
»
.NET
»
ASP.NET
»
How to form query dynamically for linq
Posted Date:
29 Jun 2012
Posted By::
AlluriAshokkumar
Member Level:
Silver
Member Rank:
1728
Points
: 5
Responses:
1
actually I am using Session Datatable
how select the multiple where conditions like
in Sql WHERE Name='' AND User='' AND Num=''
like
if (SearchDomains != "")
{
if (date1 != "" && date2 != "")
{
query = query + " and ";
}
query = query + "MyDomains LIKE '" + SearchDomains + "%'";
}
if (DomianStatus != "")
{
if (date1 != "" && date2 != "" || SearchDomains != "")
{
query = query + " and ";
}
query = query + "StatusToolTip ='" + DomianStatus + "'";
}
if (NoDays != "")
{
if (date1 != "" && date2 != "" || SearchDomains != "" || DomianStatus != "")
{
query = query + " and ";
}
Double Days = Convert.ToDouble(NoDays);
ExpSart = DateTime.UtcNow;
ExpEnd = DateTime.UtcNow.AddDays(Days);
query = query + "EndDate >='" + ExpSart + "' and EndDate <='" + ExpEnd + "' ";
}
how can i form this type of query in LINQ ,
how can i pass this query in linq
Tweet
Responses
#678157 Author:
Mohan M Devarinti
Member Level:
Gold
Member Rank:
488
Date: 29/Jun/2012 Rating:
Points
: 4
Hi,
you can try like this:
var result = from p in pssContext.Users
select p;
string strUid = "";
if (!string.IsNullOrEmpty(txtFilterName.Text))
{
result = result.Where(p => p.Name.Equals(txtFilterName.Text));
}
if (!string.IsNullOrEmpty(strUid))
{
result = result.Where(p => p.UserId.Equals(strUid));
}
if it vl not help this, then ref the link:
http://www.albahari.com/nutshell/predicatebuilder.aspx
http://www.albahari.com/nutshell/predicatebuilder.aspx
Regards,
Murali
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 :
How catch results of stored procedure in asp.net page
Previous :
Generate user name with a,b,c,d .......
Return to Discussion Forum
Post New Message
Category:
Related Messages
Validation Controls
no of click on advertisement in asp.net application
Please Please help.................. tooo urgent
Please tell me .Net interview Questions for 2+ Years Exp
To upload Documents like(doc,pdf,etc) to file system
Active Members
Today
Jivani
(23)
naveensanagase...
(21)
Asheej T K
(20)
Last 7 Days
baskar
(303)
Ultimaterengan
(267)
Rakesh Chaubey
(184)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds