标签:
在EF编程中我们可以通过lamda表达式可以进行查询数据,获取到IQueryable<T>结果,我们要想知道具体的SQL语句是什么需要使用ObjectQuery<T>进行处理
处理方法如下:
IQueryable<Data> data = this.ObjectContext.Data.Where(d => d.Name.StartsWith("测试")); ObjectQuery<Data> oq=data as ObjectQuery<Data>; String sql=oq.ToTraceString();
SELECT [Extent1].[ID] AS [ID], [Extent1].[Name] AS [Name] FROM (SELECT [Data].[ID] AS [ID], [Data].[Name] AS [Name] FROM [dbo].[Data] AS [Data]) AS [Extent1] WHERE [Extent1].[Name] LIKE '测试%'
标签:
原文地址:http://blog.csdn.net/lijun7788/article/details/46671009