Sql-Linq-Lambda对照表
Posted by-lhc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sql-Linq-Lambda对照表相关的知识,希望对你有一定的参考价值。
SELECT * FROM Employee |
from e in Employees select e |
Employees.Select(e => e) |
SELECT ID, Title FROM Employee |
from e in Employees select new {ID = e.ID, Title = e.Title} |
Employees.Select(e => new {ID = e.ID, Title = e.Title}) |
SELECT DISTINCT Title FROM Employee |
(from e in Employees select e.Title).Distinct() |
Employees.Select(e => e.Title).Distinct () |
SELECT e.* FROM Employee AS e WHERE e.ID = 1 |
from e in Employees where e.ID == 1 select e |
Employees.Where(e => (e.ID == 1)) |
SELECT e.* FROM Employee AS e WHERE e.ID = 1 AND(OR) e.Flag = 1 |
from e in Employees where e.ID == 1 &&(||) e.Flag select e |
Employees.Where(e => ((e.ID == 1) &&(||) e.Flag)) |
SELECT e.* FROM Employee AS e WHERE e.ID >= 1 AND(OR) e.ID <= 3 |
from e in Employees where e.ID >= 1 &&(||) e.ID <= 3 select e |
Employees.Where(e => ((e.ID >= 1) &&(||) (e.ID <= 3))) |
SELECT e.* FROM Employee AS e ORDER BY e.ID |
from e in Employees orderby e.ID select e |
Employees.OrderBy(e => e.ID) |
SELECT e.* FROM Employee AS e ORDER BY e.ID DESC, e.Title |
from e in Employees orderby e.ID descending, e.Title select e |
Employees.OrderByDescending(e => e.ID).ThenBy (e => e.Title) |
SELECT SUM(e.Times) FROM Employee |
Employees.Sum(e => e.Times) | |
SELECT e.Title, SUM(e.Times) AS TotalTimers FROM Employee AS e GROUP BY e.Title |
from e in Employees group e by e.Title into g select new {Title = g.Key, TotalTimers = g.Sum(e => e.Times)} |
Employees.GroupBy(e => e.Title).Select( g => new {Title = g.Key, TotalTimers = g.Sum(e => e.Times)} ) |
以上是关于Sql-Linq-Lambda对照表的主要内容,如果未能解决你的问题,请参考以下文章