none
From SQL query to LINQ RRS feed

  • Question

  • Hi guys!

    Someone may translate these SQL Queries to LINQ Queries please? :

    1st query

    select P1.Name from surveydetails S1, Product P1,productonassortment A1  
    where S1.idsurvey = 'a0S5700001Gz1PMEAZ'
    and S1.Idproduct = P1.id
    and ismissing = 1
    and P1.id = A1.idproduct
    and A1.isactive;

    2nd query

    select P1.Name from surveydetails S1, Product P1, productonassortment A1 where S1.idsurvey = 'a0S5700001Gz1PMEAZ'
    and S1.Idproduct = P1.id
    and P1.id = A1.idproduct
    and isoutofstock = 1
    and A1.isactive;

    3rd query

    select A1.idproduct 
    from  productonassortment A1 , assortment A2 
    where 
    A2.id = 'a0ID000000DwILcMAN'
    and A2.active = 1
    and A2.id= A1.idassortment
    and A1.isactive
    and A1.idproduct not in (select idproduct from surveydetails where idsurvey = 'a0S5700001Gz1PMEAZ' );

    Thank you for your help!

    Thursday, October 12, 2017 1:40 PM

Answers

  • Hi,

    1st Cross Join Query: ismissing is ?

           var query = from s in db.surveydetails
                        from p in db.Product
                        from a in db.productonassortment
                        where s.idsurvey == 'a0S5700001Gz1PMEAZ' 
                        &&  s.Idproduct = p.id
                        && p.id = a.idproduct
                        && a.isactive==true
                        select p.name;

    2st Query: isoutofstock is ?

     var query = from s in db.surveydetails
                        from p in db.Product
                        from a in db.productonassortment
                        where s.idsurvey == 'a0S5700001Gz1PMEAZ'
                        && s.Idproduct = p.id
                        && p.id = a.idproduct
                        && a.isactive ==true
                        select p.name;

    3st Query:

            var query = from a1 in db.surveydetails
                        from a2 in db.assortment
                        where a2.id == 'a0ID000000DwILcMAN'
                        && a2.active == 1
                        && a2.id = a1.idassortment
                        && a1.isactive ==true
                        && a1.idproduct
                        && ! (from s db.surveydetails select s.idproduct where idsurvey = 'a0S5700001Gz1PMEAZ').Contains(a1.idproduct)
            select a.idproduct;

    Best Regards,

    Bob



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by DiddyRennes Monday, October 16, 2017 8:53 AM
    Saturday, October 14, 2017 11:22 AM