C# .NET EF core 多表联合多条件模糊查询
作者:互联网
今天遇到多表联合模糊查询的功能 遇到多个多表联合多条件模糊查询 的功能实现
记录一下
//获取总记录数 var totalRows = (from c in _dbContext.ChildOrders join o in _dbContext.Orders on c.OrderId equals o.Id join p in _dbContext.Platforms on o.PlatformId equals p.Id where (c.Deleted == false && c.Disable == false && o.Deleted == false && o.Disabled == false && o.Uid == int.Parse(HttpContext.User.Identity.Name) && (string.IsNullOrEmpty(CID.ToString()) ? true : c.Id.Equals(CID)) && (string.IsNullOrEmpty(PlatformId.ToString()) ? true : o.PlatformId.Equals(PlatformId)) && (string.IsNullOrEmpty(school) ? true : o.School.Contains(school)) && (string.IsNullOrEmpty(username) ? true : o.UserName.Contains(username)) && (string.IsNullOrEmpty(className) ? true : c.Name.Contains(className)) && (string.IsNullOrEmpty(runstatus.ToString()) ? true : c.RunStatus.Equals(runstatus)) ) select c).Count();
主要用了三目运算符 过滤掉null值条件 否则搜索不到数据
标签:core,多表,string,C#,PlatformId,&&,false,IsNullOrEmpty,true 来源: https://www.cnblogs.com/Echoxxx/p/16369373.html