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對照表