after migrating from ef core 3.1 to ef core 5, I encountered this error in executing the following code when return IntersectList
System.ArgumentException: 'must be reducible node'
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;
}
What should I fix?
im found
Instead of this line:
I modified it this way :