C# EF+LINQ 高性能Like语法
C# EF+LINQ 高性能Like语法:
用法1:
C# 全选
using EFEx = Microsoft.EntityFrameworkCore.EF;
q.Where(w=>EFEx.Functions.Like(w.ProductName, $"%{input.content}%"));
用法2:
C# 全选
public List<sys_DocType> Query(string content)
{
var q = _Database.GetQueryable<sys_DocType>();
if (!String.IsNullOrEmpty(content))
{
q = q.Where(w => false
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.DocCode, $"%{content}%")
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.FormName, $"%{content}%")
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.FormNameSpace, $"%{content}%")
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.FormCaption, $"%{content}%")
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.KeyFieldName, $"%{content}%")
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.TableName, $"%{content}%")
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.TableDescription, $"%{content}%")
|| Microsoft.EntityFrameworkCore.EF.Functions.Like(w.Remark, $"%{content}%")
);
}
return q.ToList();
}
大数据不建议使用:
C# 全选
.Where(w=>(w.ProductName ?? "").Contains(input.content));
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网