使用EntityFramework时,怎样获得新增,修改,删除时的SQL语句
发布网友
发布时间:2022-04-09 02:53
我来回答
共1个回答
热心网友
时间:2022-04-09 04:22
myContext context = new myContext();
string esql = "SELECT VALUE it FROM myContext.DBItemList as it";
ObjectQuery<DBItemList> query = context.CreateQuery<DBItemList>(esql);
Console.WriteLine(query.CommandText);//获取esql
Console.WriteLine(query.ToTraceString());//获取sql
输出结果:
SELECT VALUE it FROM myContext.DBItemList as it
SELECT
[Extent1].[AutoId] AS [AutoId],
[Extent1].[NameID] AS [NameID],
[Extent1].[ItemID] AS [ItemID],
[Extent1].[ItemValue] AS [ItemValue]
FROM [dbo].[DBItemList] AS [Extent1]