Trying to execute a WHERE IN: Invalid 'where' condition. An entity member is invoking an invalid property or method

穿精又带淫゛_ 提交于 2019-12-02 02:24:16
Peter Majeed

The problem is the CRM Linq Provider. It doesn't support all of the available options that the Linq-to-objects provider offers. In this case, the CRM does not support the Enumerable.Contains() method.

where: The left side of the clause must be an attribute name and the right side of the clause must be a value. You cannot set the left side to a constant. Both the sides of the clause cannot be constants. Supports the String functions Contains, StartsWith, EndsWith, and Equals.

You can work around this in one of two ways:

  1. Rework your query to use a more natural join.
  2. If a join is not possible, you can use Dynamic Linq to generate a list of OR clauses on each item in customerIDs. This would function similarly to Enumerable.Contains.

See my answer or the accepted answer to the question "How to get all the birthdays of today?" for two separate ways to accomplish this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!