How to write query with IN operator

3 posts, 1 answers
  1. Ratndeep
    Ratndeep avatar
    40 posts
    Member since:
    Feb 2009

    Posted 06 Jan 2010 Link to this post

    Hi ,
    I have  a table Role with fields RoleId and Name.I have to write a query something like that
    select * from Role where RoleId in (1,2,3). but somehow not able to  get the equivalent of in operator in OA Linq.
    Please Help 

    where  could i find some join samples in the Linq for  Q3 release on telerik site .

    Thanks
    Ratndeep
  2. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 07 Jan 2010 Link to this post

    Hi Ratndeep,

    You can use the Contains() method of a List collection as follows:
    List<int> ids = new List<int>() { 1, 2, 3 };
     
    var result = (from x in scope.Extent<Role>()
            where ids.Contains(x.RoleId)
            select x).ToList();

    You could find some Linq join samples in our C# Linq Examples application which is distributed with the product. There should be a shortcut in your start menu under Telerik -> OpenAccess ORM.
    Hope that helps.

    Sincerely yours,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Ratndeep
    Ratndeep avatar
    40 posts
    Member since:
    Feb 2009

    Posted 07 Jan 2010 Link to this post

    Thanks Alexander.It worked.You guys are great !
Back to Top