Como faço para implementar uma cláusula dinâmica 'where' no LINQ?
Eu quero ter uma dinâmicawhere
condição.
No exemplo a seguir:
<code>var opportunites = from opp in oppDC.Opportunities join org in oppDC.Organizations on opp.OrganizationID equals org.OrgnizationID where opp.Title.StartsWith(title) select new { opp.OpportunityID, opp.Title, opp.PostedBy, opp.Address1, opp.CreatedDate, org.OrganizationName }; </code>
Algumas vezes eu tenhoTitle
e às vezes eu não. E também quero adicionar data emwhere
cláusula dinamicamente.
Por exemplo, como este SQL:
<code>string whereClause; string SQL = whereClause == string.Empty ? "Select * from someTable" : "Select * from someTable" + whereclause </code>