Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sumit JoshiRank #1,252 · 1.4K reputationPosted Sep 21, 2015, 9:18 AM EDT
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.var em = from e in emp group e by new { e.Salary, e.Id } into gEmp let avgsal = (gEmp.Sum(t => t.Salary) / gEmp.Count()) where gEmp.Key.Salary == avgsal select new { gEmp.Key.Salary, gEmp.Key.Id };Guest UserRank #816 · 2.8K reputationPosted Sep 21, 2015, 1:20 AM EDT
Anil KumarRank #942 · 2.2K reputationPosted Sep 22, 2015, 6:22 AM EDT
Sumit JoshiRank #1,252 · 1.4K reputationPosted Sep 22, 2015, 7:29 AM EDT