Entity Framework学习初级篇4--Entity SQL
其属性,esql语句如下:
SELECT ref(c).CustomerID FROM NorthwindEntities.Customers as c order by c.CustomerID LIMIT 10 deref运算符取消引用一个引用值,并生成该取消引用的结果。 l CASE语句: string esql = "using SqlServer;select case when len(trim(c.CustomerID))==0 then true else false end from NorthwindEntities.Customers as c order by c.CustomerID limit 10"; l 运算符 Esql支持的运算符有:加+、减-、乘*、除/、取模%、-负号。Esql语句如下: select 100/2 as OP from NorthwindEntities.Customers as c order by c.CustomerID limit 10 l 比较运算符 Esql支持的比较运算符有:=,>,>=,IS [NOT] NULl ,<,[NOT] BETWEEN,!=,<>,[NOT] LIKE。Esql语句如下: select value p from NorthwindEntities.Products as p where p.UnitPrice > 20 order by p.ProductID limit 10 l 逻辑运算符 Esql支持的逻辑运算符有:and(&&),not(!),or(||)。Esql语句如下: select value p from NorthwindEntities.Products as p where p.UnitPrice > 20 and p.UnitPrice<100 order by p.ProductID limit 10 或 select value p from NorthwindEntities.Products as p where p.UnitPrice > 20 && p.UnitPrice<100 order by p.ProductID limit 10 l 字符串连接运算符。 加号(+)是Entity SQl中可将字符串串联起来的唯一运算符。Esql语句如下: select c.CustomerID + c.ContactName from NorthwindEntities.Customers as c order by c.CustomerID limit 10 l 嵌套查询 在Entity SQl中,嵌套查询必须括在括号中,将不保留嵌套查询的顺序 select c1.CustomerID from( select value c from NorthwindEntities.Customers as c order by c.CustomerID limit 10) as c1 l 日期时间函数 Esql提供的日期时间函数有:CurrentDateTime()获取当前服务器的日期时间,还有month,day,year,second, Minute ,Hour等。例如: select CurrentDateTime() from NorthwindEntities.Customers as c order by c.CustomerID limit 10 l 字符串函数 Esql提供的字符串函数有:Concat,IndexOf,Left,Length,Ltrim,Replace,Reverse,Rtrim,SubString,Trim,ToLower,ToUpper.例如: select Reverse(p.ProductName) as ProductName from NorthwindEntities.Products as p order by p.ProductID limit 10 l GUID Esql提供newguid()函数,产生一个新的Guid。例如: select newguid() from NorthwindEntities.Customers as c order by c.CustomerID limit 10 l 数学函数: Abs,Ceiling,Floor,Round l 统计函数: Avg,BigCount,Count,Max,Min,StDev,Sum l 位计算函数 如果提供 Null BitWiseAnd,BitWiseNot,BitWiseOr,BitWiseXor l 命名空间 Entity SQl引入命名空间以避免全局标识符(如类型名称、实体集、函数等)出现名称冲突。Entity SQl中的命名空间支持与.NET Framework中的命名空间支持类似。 Entity SQl提供两种形式的USING子句:限定命名空间(其中,提供较短的别名以表示命名空间)和非限定命名空间,如下例所示: USING System.Data; USING tsql = System.Data; 例如: string esql = "using System; select cast(p.UnitPrice as Int32) from NorthwindEntities.Products as p order by p.ProductID limit 10 "; string esql = "using System;using SqlServer; select(cast(p.UnitPrice as Int32)),SqlServer.ltrim(p.ProductName) as nameLen from NorthwindEntities.Products as p order by p.ProductID limit 10 "; 最后,简单说一下Esql与 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |