“Invalid ‘where’ condition. An entity
member is invoking an invalid property or method.”
I
came across above error, while I was working on a LINQ query to retrieve a set
of records from a CRM 2013 custom entity. It is a CRM 2013 online environment
and I was using XrmServiceContext to retrieve data.
Even
though it appears to be that I have specified an invalid property, I found out
below line is causing the issue.
Where(d => d.nav_expirationdate.HasValue
&& ...
It
turns out that LINQ to CRM implementation expects two values in each condition
and CRM Property must be on the left hand side. Otherwise where clause will
simply crash.
Code that will Crash with Invalid 'where'
condition exception:
this.xrm.CreateQuery<nav_myrequest>().Where(d => d.nav_expirationdate.HasValue
&& ...
Code that will Work without an error:
this.xrm.CreateQuery<nav_myrequest>().Where(d => d.nav_expirationdate
!= null
&& ...
No comments:
Post a Comment