I am using linq to query data from CRM, I want to check the conditions that have values and ignore the others , I used the following code:
return (from c in CTX.CreateQuery("trainingcourse")
where CourseID == null || (Guid)c["trainingcourseid"] == CourseID
&& FromDate == null || (DateTime)c["startdate"] <= FromDate
&& ToDate == null || (DateTime)c["startdate"] >= ToDate
&& SearchText == null || ((string)c["title"]).Contains(SearchText) ||
((string)c["description"]).Contains(SearchText)
select c)
But this cause the following application error
Invalid 'where' condition. An entity member is invoking an invalid property or method.
*This post is locked for comments