Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: GroupBy aggregate value from owned entities #24591

Closed
Zetanova opened this issue Apr 5, 2021 · 2 comments
Closed

Feature: GroupBy aggregate value from owned entities #24591

Zetanova opened this issue Apr 5, 2021 · 2 comments

Comments

@Zetanova
Copy link

Zetanova commented Apr 5, 2021

With efcore 5 it is not possible to create an aggregate from an owned entity.

Following throws an exception

[Owned]
public sealed class Stats
{
     public int Value1 { get; set; }
}

var query = context.Records
.GroupBy(n => n.Category)
.Select(g => new 
{
      Category = g.Key,
      Total: g.Sum(n => n.Stats.Value1) 
});

Same query and it works

var query = context.Records
.Select(n => new 
{
      n.Category,
      n.Stats.Value1
})
.GroupBy(n => n.Category)
.Select(g => new 
{
      Category = g.Key,
      Total: g.Sum(n => n.Value1) 
});
@smitpatel
Copy link
Member

Duplicate of #22609

@smitpatel smitpatel marked this as a duplicate of #22609 Apr 5, 2021
@Zetanova
Copy link
Author

Zetanova commented Apr 5, 2021

ok, did found it

@Zetanova Zetanova closed this as completed Apr 5, 2021
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants