top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Define what is Where clause and Let clause in LINQ?

+2 votes
51 views
Define what is Where clause and Let clause in LINQ?
posted Jun 30, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

0 votes

Where clause: It allows adding some conditional filters to the query.
Let clause: It allows defining a variable and assigning it a value calculated from the data values.

LINQ Query

var objresult = from emp in objEmployee
                            let totalSalary = objEmployee.Sum(sal =>  sal.Salary)
                            let avgSalary = totalSalary / 5
                            where avgSalary > emp.Salary
                            select emp;
answer Jul 4, 2017 by Shivaranjini
0 votes

Where clause: It allows us to add some conditional filters to the query.
Let clause: It allows us to define a variable and assigning it a value calculated from the data values.

 var arr = new[] { 5, 3, 4, 2, 6, 7 };
    var sq = from int num in arr
                    let square = num * num
                    where square > 10
                    select new { num, square };

    foreach (var a in sq)
        Console.WriteLine(a);
answer May 2 by Siddhi Patel
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...