EFCore+LINQ 使用DebugView查看LINQ转译后的原生SQL
EFCore+LINQ 使用DebugView查看LINQ转译后的原生SQL
LINQ查询
C# 全选
public bool DeletePackageByKeys(List<string> listKeys)
{
var q = _Database.GetQueryable<sys_UpgraderPackageTable>().Where(w => listKeys.Contains(w.isid));
_Database.RemoveRange(q);
return true;
}
设断点跟踪Query
在GetQueryable<T>代码行设置断点,程序运行到断点行按F10到下一行,然后把鼠标放到q上面。
点击查看按钮弹出【文本可视化工具】
SqlServer数据库多条件查询Demo
Linq代码
C# 全选
var q = _Database.GetQueryable<sys_UpgraderPackageTable>();
if (!String.IsNullOrEmpty(systemName))
{
q = q.Where(w => (w.SystemName == "*" || (";" + w.SystemName + ";").Contains(";" + systemName + ";")));
}
var qs = q.Select(s => new res_PackageTable
{
VersionNo = s.VersionNo,
isid = s.isid,
SystemName = s.SystemName,
PackageType = s.PackageType,
FileVersion = s.FileVersion,
FileName = s.FileName,
FileType = s.FileType,
FileSize = s.FileSize,
CreationTime = s.CreationTime,
Remark = s.Remark,
}).OrderBy(o => o.VersionNo);
var list = qs.ToList();
转为Sql脚本
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网