【发布时间】:2021-03-09 23:56:06
【问题描述】:
从 ef core 3.1 迁移到 ef core 5 后,在执行以下代码时遇到了这个错误 返回 IntersectList 时
System.ArgumentException: '必须是可约节点'
private IQueryable<CategoryBrandDto> ToCategoryBrandDto()
{
IQueryable<CategoryBrandDto> Temp = null;
var categoriesBrands = _context.CategoriesBrands;
if (categoriesBrands != null)
{
Temp = categoriesBrands.Select(c => new CategoryBrandDto
{
CategoryId = c.CategoryId,
BrandId = c.BrandId,
Caption = c.Brand.Caption,
OriginalCaption = c.Brand.OriginalCaption,
ImageUrl = c.Brand.ImageUrl,
Arrange = c.Arrange
});
}
return Temp;
}
public IQueryable<BrandDto> GetIntersectsBrand(IEnumerable<BrandDto> filteredBrand, int categoryId)
{
var query = ToCategoryBrandDto().Where(x => x.CategoryId == categoryId).OrderBy(x=>x.Arrange);
var selectedList = new List<BrandDto>();
foreach (var item in query)
{
var cb = new BrandDto()
{
BrandDto_BrandId = item.BrandId,
BrandDto_Caption = item.Caption,
BrandDto_OriginalCaption = item.OriginalCaption,
BrandDto_ImageUrl = item.ImageUrl,
BrandDto_Arrange = item.Arrange
};
selectedList.Add(cb);
}
IQueryable<BrandDto> IntersectList = selectedList.AsQueryable().Intersect(filteredBrand, new ComparerBrand());
return IntersectList;
}
我应该解决什么问题?
【问题讨论】:
-
哪一行产生异常?
ToCategoryBrandDto()是什么?为了尝试提供帮助,我们需要可重现的示例。 -
@IvanStoev:我添加了
标签: entity-framework-core ef-core-5.0