SQL-LINQ-Lambda语法对照
|
SQL |
LINQ |
Lambda |
|
SELECT *FROM HumanResources.Employee |
from e in Employees select e |
Employees .Select (e => e) |
|
SELECT e.LoginID, e.JobTitle FROM HumanResources.Employee AS e |
from e in Employees select new {e.LoginID, e.JobTitle} |
Employees.Select ( |
|
SELECT e.LoginID AS ID, e.JobTitle AS FROM HumanResources.Employee AS e |
from e in Employees select new {ID = e.LoginID, Title = |
Employees.Select ( |
|
SELECT DISTINCT e.JobTitle FROM HumanResources.Employee AS e |
(from e in Employees select e.JobTitle).Distinct() |
Employees |
|
SELECT e.* FROM HumanResources.Employee AS e WHERE e.LoginID = 'test' |
from e in Employees where e.LoginID == "test" select e |
Employees |
|
SELECT e.* FROM HumanResources.Employee AS e WHERE e.LoginID = 'test' AND |
from e in Employees where e.LoginID == "test" select e |
Employees |
|
SELECT e.* FROM HumanResources.Employee WHERE e.VacationHours >= 2 AND |
from e in Employees where e.VacationHours >= 2 && select e |
Employees |
|
SELECT e.* FROM HumanResources.Employee |
from e in Employees orderby e.NationalIDNumber select e |
Employees |
|
SELECT e.* FROM HumanResources.Employee ORDER BY e.HireDate DESC, |
from e in Employees orderby e.HireDate descending, select e |
Employees |
|
SELECT e.* FROM HumanResources.Employee WHERE e.JobTitle LIKE 'Vice%' OR |
from e in Employees where select e |
Employees |
|
SELECT SUM(e.VacationHours) FROM HumanResources.Employee AS e |
Employees.Sum(e => e.VacationHours); |
|
|
SELECT COUNT(*) FROM |
Employees.Count(); |
|
|
SELECT SUM(e.VacationHours) AS FROM HumanResources.Employee AS e GROUP BY e.JobTitle |
from e in Employees group e by e.JobTitle into g select new {JobTitle = g.Key, |
Employees |
|
SELECT e.JobTitle, SUM(e.VacationHours) FROM HumanResources.Employee AS e GROUP BY e.JobTitle HAVING e.COUNT(*) > 2 |
from e in Employees group e by e.JobTitle into g where g.Count() > 2 select new {JobTitle = g.Key, |
Employees |
|
SELECT * FROM Production.Product AS p, |
from p in Products from pr in ProductReviews select new {p, pr} |
Products |
|
SELECT * FROM Production.Product AS p INNER JOIN Production.ProductReview AS |
from p in Products join pr in ProductReviews on p.ProductID select new {p, pr} |
Products |
|
SELECT * FROM Production.Product AS p INNER JOIN Production.ProductCostHistory |
from p in Products join pch in ProductCostHistories on new select new {p, pch} |
Products |
|
SELECT * FROM Production.Product AS p LEFT OUTER JOIN Production.ProductReview |
from p in Products join pr in ProductReviews on p.ProductID into prodrev select new {p, prodrev} |
Products |
|
SELECT p.ProductID AS ID FROM Production.Product AS p UNION SELECT pr.ProductReviewID FROM Production.ProductReview AS pr |
(from p in Products select new {ID = p.ProductID}).Union( from pr in ProductReviews select new {ID = pr.ProductReviewID}) |
Products |
|
SELECT TOP (10) * FROM Production.Product AS p WHERE p.StandardCost < 100 |
(from p in Products where p.StandardCost < 100 select p).Take(10) |
Products |
|
SELECT * FROM [Production].[Product] AS p WHERE p.ProductID IN( SELECT FROM WHERE ) |
from p in Products where (from pr in ProductReviews where pr.Rating == 5 select select p |
Products |
SQL-LINQ-Lambda语法对照的更多相关文章
- SQL,LINQ,Lambda语法对照图(转载)
如果你熟悉SQL语句,当使用LINQ时,会有似曾相识的感觉.但又略有不同.下面是SQL和LINQ,Lambda语法对照图 SQL LINQ Lambda SELECT * FROM HumanReso ...
- SQL,Linq,Lambda之间的转换练习
1.查询Student表中的所有记录的Sname.Ssex和Class列. SQL:select sname,ssex,class from Students linq:from s in Stude ...
- sql linq lambda 对比
. 查询Student表中的所有记录的Sname.Ssex和Class列. select sname,ssex,class from student Linq: from s in Students ...
- SQL-LINQ-Lambda 语法对照
SQL LINQ Lambda SELECT *FROM Employees from e in Employees select e Employees .Select (e => e) ...
- SQL/LINQ/Lamda 写法[转发]
SQL LINQ Lambda SELECT * FROM HumanResources.Employee from e in Employees select e Employees .Sele ...
- SQL Linq lamda区别
SQL LINQ Lambda SELECT * FROM HumanResources.Employee from e in Employees select e Employees .Sele ...
- SQL/LINQ/Lamda
SQL LINQ Lambda SELECT * FROM HumanResources.Employee from e in Employees select e Employees .Sele ...
- SQL-LINQ-Lambda语法对照,好记性不如烂笔头
忘记的时候就翻阅翻阅吧~~ SQL LINQ Lambda SELECT *FROM HumanResources.Employee from e in Employees select e Empl ...
- LINQ之路 4:LINQ方法语法
书写LINQ查询时又两种语法可供选择:方法语法(Fluent Syntax)和查询语法(Query Expression). LINQ方法语法是非常灵活和重要的,我们在这里将描述使用链接查询运算符的方 ...
随机推荐
- 169. Majority Element(C++)
169. Majority Element Given an array of size n, find the majority element. The majority element is t ...
- Win32中GDI+应用(四)--- 位图的打开与显示
显示位图,你应该使用GDI+里面的Bitmap类或者Image类,这两个类都提供了方法从硬盘上的一个文件打开文件,创建相应的内存中的位图对象的工作.然后你可以使用Graphics类的DrawImage ...
- 【原创】The Error in Android developing
本文停止更新.... 鼠标渣渣 ,点一次 成两次 R.java文件不幸中枪 被拖动修改... 最后application编译运行时 解决方案:project-clean 问题解决了.. 2 ...
- Curl 采集乱码 gzip 原因及解决方案 utf-8
用curl获取一个经过gzip压缩后的网页时返回乱码 原因大体就是服务器返回的Content-Encoding的值和网页的编码不同,造成curl解码出问题,直接将gzip或deflate编码的文件下载 ...
- webform的三级联动
webform的三级联动 与winform一样,只不过需把DropDownList的AutoPostBack属性改为True. *简单日期的编写方法:用是三个DropDownList分别代表年月日,用 ...
- iOS:NAV+TABLE结合
功能:点击列表项,用列表字符串作为参数创建一个新视图,新视图默认可以有一个BACK按钮回到上一个视图 // // main.m // Hello // // Created by lishujun o ...
- jQuery中的data方法:
向元素附加数据,然后取回该数据: $("#btn1").click(function(){ $("div").data("greeting" ...
- Swift入门系列--Swift官方文档(2.2)--中文翻译--About Swift 关于Swift
About Swift 关于Swift 官方文档的翻译,仅供参考,本人英语本就不好,边学边翻译,不喜勿喷. Swift is a new programming language for iOS, O ...
- 用POLL的方式,没有跑出结果来,立此存照
咦,这些内容,和我以前看内核时的东东,对应起来了.. SELECT,POLL,EPOLL,非阻塞,异步之类的... 但我没有调出来.回家有空了可以看看,不用再敲打代码啦... #!/usr/bin/e ...
- Spring整合CXF,发布RSETful 风格WebService
原文地址:http://www.cnblogs.com/hoojo/archive/2012/07/23/2605219.html 这篇文章是承接之前CXF整合Spring的这个项目示例的延伸,所以有 ...