【Bug】Lambda expression used inside Include is not valid
BUG not is lambda valid include expression used
2023-09-11 14:14:50 时间
问题代码
Include中使用的Lambda表达式无效
List<BizDictionary> dics = DBServerProvider.DbContext
.Set<BizDictionary>()
.Where(x => x.IsEnable == 1)
.Include(c => c.BizDictionaryDetailList.Where(f=>f.IsEnable==1)).ToList();
原因
可能是EF Core版本太低不支持 当前版本3.1.16 要5.0及以上
EF Core 5.0 中的新增功能
解决
改用select后处理子表
List<BizDictionary> dics = DBServerProvider.DbContext
.Set<BizDictionary>()
.Where(x => x.IsEnable == 1)
.Include(c => c.BizDictionaryDetailList).Select(f=>new BizDictionary
{
Id=f.Id,
OrderNo=f.OrderNo,
DicName=f.DicName,
DicNo=f.DicNo,
Config=f.Config,
DicUrl=f.DicUrl,
DicValueKey=f.DicValueKey,
Remark=f.Remark,
IsEnable=f.IsEnable,
DicNameKey=f.DicNameKey,
DicType=f.DicType,
BizDictionaryDetailList=f.BizDictionaryDetailList.Where(f=>f.IsEnable==1).ToList()
}).ToList();
相关文章
- 【Bug】No module factory available for dependency type: CssDependency
- 修复ext4日志(jbd2)bug( Ext4 文件系统有以下 Bug)
- EasyUI之Form load函数IE8下设置Radio或Checkbox的BUG
- 我非要把这个bug优雅的解决掉 | k8s记录events报错:Could not construct referenc
- 一个漏测Bug能让你想到多少?
- Kilim的小BUG
- Blog2.0新版本发布和解决Bug列表-2007.3.25
- 空格、逗号!你都遇到哪些奇葩bug呢?
- 记一次生产Slor分组的bug
- Dumpzilla工具第615行bug的解决办法
- Ueditor1.3.6 setContent的一个bug
- zabbix调试脚本报错(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)
- Spring Cloud Dalston.SR5 BUG一记
- 【Unity3D日常BUG】(二)Unity3d打包APK出现SDK版本问题解决
- vue Inline JavaScript is not enabled. Is it set in your options?
- 遭遇多线程bug (1)
- IOS开发之Bug--遇到一个类型不确定的bug
- 加速修复bug Windows 10周年更新8月2日上线