提问人:Luis Santos 提问时间:9/29/2023 最后编辑:Luis Santos 更新时间:9/29/2023 访问量:34
无法使用 EFCore.BulkExtensions 将类型为“System.Linq.EmptyPartition1[Model]”的对象强制转换为类型“System.Collections.Generic.List1[Model]”
Unable to cast object of type 'System.Linq.EmptyPartition1[Model]' to type 'System.Collections.Generic.List1[Model]' using EFCore.BulkExtensions
问:
我正在使用 EFCore 7.0 和 EFCoreBulkExtensions 7.1.2
当我尝试执行一个
_context.BulkUpdate(list, bulkConfig);
它如何:<System.InvalidCastException>
Unable to cast object of type 'System.Linq.EmptyPartition1[ModelX]' to type 'System.Collections.Generic.List1[ModelX]'
该列表不为空,它包含 ModelX 类的元素
对此有任何线索吗?
我已经尝试将列表作为 List<>、IList<> 和 IEnumerable 传递<>并出现相同的错误。
答:
0赞
Luis Santos
9/29/2023
#1
我更改了 .BulkUpdate() 方法。UpdateRange()
由此
_context.BulkUpdate(list, bulkConfig);
对此
_context.UpdateRange(list);
_context.SaveChanges();
现在它正在工作,希望能帮助另一个迷失的开发人员寻找轻:D
评论