Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
var exp = ProjectDomains.Where(s => s.FKProjectId == projid && s.DomainEnvironment == Environment )
In above linq query "projid ","Environment " values are passing from user .if either one of the values passed null.I want the filter with passed parameter only neglecting null parameter.
How can i achieve this?
Posted

1 solution

C#
(projid is null || s.FKProjectId == projid) && (Environment is null || s.DomainEnvironment == Environment)
 
Share this answer
 
Comments
Venkata Durga Rao 10-Jun-15 6:51am    
from p in db.ProjectDomains where (p.FKProjectId == projid || projid is null) select p;

when am trying this "Type Expected" issue raises in place of null
Kornfeld Eliyahu Peter 10-Jun-15 6:58am    
Sorry...I mixed C# and SQL a bit (a lot)...
It should be projid == null instead of projid is null
Venkata Durga Rao 10-Jun-15 10:10am    
Tnx

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