-
Notifications
You must be signed in to change notification settings - Fork 3.3k
must be reducible node on one descendant class #14758
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
private IQueryable<T> GetBasePostSearchQuery<T>(string searchString, string sortOrder) where T : Post
{
var posts = _context.Posts.OfType<T>();
return posts;
}
public async Task<IList<PostSearchCategory>> GetPostSearchCategoriesAsync<T>(string searchString) where T : Post
{
var query = GetBasePostSearchQuery<T>(searchString, null);
var result = await query.GroupBy(p => new { ((ICategorizedPost)p).Category, ((ICategorizedPost)p).Category.Slug })
.AsNoTracking()
.Select(p => new PostSearchCategory { Name = p.Key.Category.Name, Slug = p.Key.Slug, Count = p.Count() })
.Where(p => p.Count > 0)
.OrderBy(p => p.Name)
.ToListAsync();
return result;
} This is where it happens. |
Casting to interface type may not work properly in EF Core because we lose model information once you do that. |
That's actually a newer thing I did as I tried to fix this in my actual project. I originally had two (nearly) identical methods that didn't use generics but the actual type and I ended up with the same result. |
Is there a reason why this would work in one class and not another? I assume it's the way they share a property name but I map to different column names? Anything I can do to workaround in the interim? |
|
https://github.com/natelaff/reduciblenode
I tried to reproduce this as best I could, but failed to do so.
I have a base type (Post), and two descendant classes, (SubpostA, SubpostB), each with a reference property "Category"
When trying to select a count of assigned category for posts, I get the must be reducible node error.
In this example, you can see it when clicking the two links on the index page.
The weird thing however is in my application, it works for SubpostA class, but the error only throws on SubpostB. In the attached example, it happens on both.
This is newer behavior, as it used to work in 2.x somewhere.
The text was updated successfully, but these errors were encountered: