首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

Entity SQL 运用技巧

2012-12-15 
Entity SQL 使用技巧1.由Entity SQL获得标准SQL语句Entity to Linq:string sql(this.ObjectContext.IrrLR

Entity SQL 使用技巧

1.由Entity SQL获得标准SQL语句

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中执行查询语句:

 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方法执行!

 

热点排行