You must Sign In to post a response.
  • Category: LINQ

    Need query in LINQ for sql query

    I NEED LINQ QUERY FORMAT FOR BELOW SQL QUERY

    select * from t_RoleAssignment where ID=524026 and roleid in (SELECT roleid FROM T_ROLES WHERE ROLE=1)
  • #764165
    Hai Pradeep,
    You can get various examples of writing the Linq query for the inner sql statements.
    Below I have just written it but not tested:

    var query =
    from c in RoleAssignmentObject
    where c.ID == 524026 &&
    !(from cc in ROLESObject
    where cc.ROLE == 1
    select cc.ID)
    select c;

    You can also go through the below link and tweak if its not working:

    http://stackoverflow.com/questions/1297831/inner-queries-in-linq

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #766187
    hi

    var results = from c in RoleAssignmentObject
    join p in ROLESObject on c.roleid equals p.roleid
    where p.ID== 524026
    select new
    {
    //-- you can mention column list here
    }

    Hope it will help you

    Thanks
    Umesh Bhosale


Sign In to post your comments