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

Manual join on aggregates are not supported #38

Closed
Shaddix opened this issue Jun 30, 2017 · 4 comments
Closed

Manual join on aggregates are not supported #38

Shaddix opened this issue Jun 30, 2017 · 4 comments

Comments

@Shaddix
Copy link
Contributor

@Shaddix Shaddix commented Jun 30, 2017

Let's say I want to display the list of Blogs and for each blog I want to display the Post which has maximum of likes (in reality, quite often the last post is displayed, i.e. having Max Date).

So, I want a query like that:

var query = db.Posts.GroupBy(x => x.BlogId).Select(x => new
                {
                    BlogId = x.Key,
                    MaxLikes = x.Max(z => z.LikeCount)
                });

                var query1 = db.Posts.
                    Join(
                        query,
                        (p, b) => p.BlogId == b.BlogId && p.LikeCount == b.MaxLikes,
                        (p, b) => new { PId = p.PostId, b.BlogId },
                        DbJoinType.LeftInner);

fix is in the works

@Shaddix
Copy link
Contributor Author

@Shaddix Shaddix commented Jun 30, 2017

@ethanli83 could you please help me with this one?
I added a couple of tests to
https://github.com/Shaddix/EFSqlTranslator/blob/ManualJoinOnAggregation/EFSqlTranslator.Tests/TranslatorTests/ManualJoinTranslationTests.cs

and fixed an exception happening when join on aggregate.
I even make these new test pass by commenting lines 45-47 in JoinTranslator.cs, but that's obviously wrong (and it makes the other Manual join test fail).

Could you please help me with this issue?

@ethanli83
Copy link
Owner

@ethanli83 ethanli83 commented Jun 30, 2017

Of course @Shaddix, I will have a look at it.

ethanli83 added a commit that referenced this issue Jun 30, 2017
 - make sure columns are created using correct ref
@ethanli83
Copy link
Owner

@ethanli83 ethanli83 commented Jun 30, 2017

hi @Shaddix,

I have fixed the issue and pushed out a new version 1.2.9. It also contains your pull requests.

@ethanli83 ethanli83 closed this Jun 30, 2017
@Shaddix
Copy link
Contributor Author

@Shaddix Shaddix commented Jun 30, 2017

thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.