管理员
|
楼主#
更多
发布于:2012-12-13 15:08
 | |  |  | Entity SQL使用技巧 1.由Entity SQL获得标准SQL语句 www.atcpu.com Entity to Linq: string sql=(this.ObjectContext.IrrLRoles.Where(d => d.rname.StartsWith("a")) as ObjectQuery).ToTraceString(); 标准SQL: SELECT [Extent1].[rid] AS [rid], [Extent1].[rname] AS [rname], [Extent1].[state] AS [state], [Extent1].[sysfuns] AS [sysfuns]FROM [dbo].[IrrLRoles] AS [Extent1]WHERE [Extent1].[rname] LIKE 'a%' 2.在Entity SQL中执行查询语句: www.atcpu.com string ids = "1,2,3,4,5,6,7,8"; return this.ObjectContext.ExecuteStoreQuery<IrrlSysFun>("select * from IrrlSysFun as s where s.nodeid in ("+ids+")").AsQueryable(); 通过ExecuteStoreQuery方法执行!
| |  | |  |
|