Select entities where ID in int array - WCF Data Services, LINQ

后端 未结 3 473
不思量自难忘°
不思量自难忘° 2020-12-19 09:27

I would like to return a set of entities who has and ID that is contained in a list or array of IDs using LINQ and Data Services. I know how to this using LinqToEF but I am

3条回答
  •  庸人自扰
    2020-12-19 09:49

    Thank you men you really helped me :) :)

    I did it like Vitek Karas said.

    1) Download the Dynamic query library Check this link

    No need to read it just download the Dynamic query library

    2)Check the project named DynamicQuery. In it you will find a class named Dynamic.cs . Copy It to your project

    3)Generate your project( If you are using silverlight an error that say ReaderWriterLock is not found will appear. Don't be affraid. Just comment or delete the lines that make errors( there is just 6 or 7 lines that make errors) )

    4) All done you just need now to write your query Example: ordersContext.CLIENTS.Where(" NUMCLI > 200 || NUMCLI < 20");

    All done. If you have to use the 'Contains' method you just to write a method that iterate over your array and return the string that your request will use.

        private string MyFilter()
    {    string st = "";
    
           foreach(var element in myTab)
           {
                  st = st + "ThePropertyInTheTable =" + element + "||"; 
            }
    
            return st;
    }
    

    I hope you understand me and that i helped someone :)

提交回复
热议问题