LINQ是一个不错的东西,我一直都这么觉得。很多朋友对他的语法都感到好奇,因为它很多地方确实与T-SQL很类似。但也有不同的地方。下面我整理了一个对照表
T-SQL关键字 | LINQ表达式关键字 | LINQ扩展方法 |
Select | Select | Select,SelectMany |
Top | Take,Takewhile | |
Distinct | Distinct | |
From | From … In… | |
Where | Where | Where |
Group By | Group… By… Into… | |
Order By | OrderBy… | OrderBy,OrderByDescending |
Join… On… | JOIN … ON … Into… | Join, GroupJoin |
Union | Union | |
Except | Except | |
Intersect | Intersect | |
Max | Max | |
Min | Min | |
Avg | Average | |
Sum | Sum | |
Count | Count,LongCount | |
First | First,FirstOrDefault | |
Last | Last,LastOrDefault | |
Skip,SkipWhile | ||
Single | ||
Any | ||
All |