Entity SQL使用技巧
1.由Entity SQL获得标准SQL语句
www.2cto.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],
FROM [dbo].[IrrLRoles] AS [Extent1]
WHERE [Extent1].[rname] LIKE 'a%'
2.在Entity SQL中执行查询语句: www.2cto.com
string ids = "1,2,3,4,5,6,7,8";
return this.ObjectContext.ExecuteStoreQuery("select * from IrrlSysFun as s where s.nodeid in ("+ids+")").AsQueryable();
通过ExecuteStoreQuery方法执行!