none
Help learning and converting Query into LINQ RRS feed

  • Question

  • I'm trying to learn LINQ. I read a lot of articals for beginners but they were out of my league

    Please help me with these simple query then I might understand these

    please convert these query for me so I might get wats is it about and I'll be very thankfull for that

    SELECT * FROM tblMenu

    this one with two values

    SELECT name, designation FROM tblEmployee

    and this with WHERE

    SELECT name, designation FROM tblEmployee
    WHERE employeeId=@id

    This one with INNER JOIN

    SELECT name, tblSalary FROM tblEmployee
    INNER JOIN tblSalary ON tblsalary.salaryId=tblEmployee.salaryId

    and this one selects the SECOND HIGHEST SALARY

    SELECT min(salary) FROM (SELECT TOP 2 salary FROM tblSalary ORDER BY 1 desc)a

    please help me with this I'll be very greatful



    • Moved by Bob Beauchemin Wednesday, April 9, 2014 5:00 PM Moved to a more appropriate forum
    Wednesday, April 9, 2014 12:49 PM

Answers


  • First Query:

    var result = from p in tblMenu
                 select p; 

    Second Query:

    var result = from p in tblMenu
                 select p.name, p.designation ; 

    Third Query:

    var result = from p in tblMenu
                 where p.employeeid = somevariable
                 select p.name, p.designation ; 

    Fourth Query:

    var result = from p in tblEmployee
                 join p2 in tblSalary  on p.salaryId equals p2.salaryId
                 select new { p.name, p2.tblSalaryId}
    Wednesday, April 9, 2014 2:01 PM

All replies