¿Cómo implemento una cláusula dinámica "dónde" en LINQ?
Quiero tener una dinamicawhere
condición.
En el siguiente ejemplo:
<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>
Algunas veces tengoTitle
y a veces no lo hago. Y también quiero añadir la fecha en.where
cláusula dinámicamente.
Por ejemplo, como este SQL:
<code>string whereClause; string SQL = whereClause == string.Empty ? "Select * from someTable" : "Select * from someTable" + whereclause </code>