locked
How do I use "in" where clause in LINQ when retrieving records/entities in Microsoft CRM? RRS feed

  • Question

  • Hello. I'm just having some problems with LINQ and Microsoft CRM and I hope you can help.

    in SQL terms I am thinking along the lines of:

     select * from table where id in ("1", "2", "3")

    I have this code and it works fine when retrieving records off a SQL Server.

         var _records = from _adUserDatas in _adUserDataDBDataContex.ADUserDatas
             where
                  _list.Contains(_adUserDatas.id)
             orderby _adUserDatas.fan
             select _adUserDatas;
    When I changed it to use the contacts entity in Microsoft CRM, it is throwing an exception and it says my where clause is not valid.


    Any ideas how to get it to work?

    thanks

    Friday, July 11, 2014 3:23 AM

All replies

  • Hi,

    It appears when you're using Contact entity, you probably don't have field "fan". Can you post your complete code?


    Admin QuikView Solution for CRM 2013


    Friday, July 11, 2014 4:54 AM
  • I guess the _list in the where clause causes the problem. Is it a list variable which you have declared? In the where clause you should be querying something of the _adUserDatas table.

    Sachith Chandrasiri

    Friday, July 11, 2014 6:04 AM