what is the use of into and let in LINQ. please help
what is the use of into and let in LINQ. please help
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sumit JoshiPosted Sep 21, 2015, 1:18 PM
Intokeyword allows creating a temporary variable to store the results of a group, join, or select clause into a new variable.group e by new{ e.DeptId}into gEmp
where gEmp.Count() > 1
select new { gEmp.Key.DeptId, salary = gEmp.Sum(t => t.Salary) };
In the above query, after applying
intoon grouping, it creates aIGroupingtypegEmpvariable, which is used to apply the next filter.Note:
Intois used when you want to perform an operation on grouped data.Let : The
Letkeyword allows storing the results of a query which can be used in a subsequent query; i.e., it creates a new variable and initializes it with the result of the expression you supply.Sumit JoshiPosted Sep 22, 2015, 11:29 AM
Anil KumarPosted Sep 22, 2015, 10:22 AM
Guest UserPosted Sep 21, 2015, 5:20 AM