We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Using EF Core RC2.
Issue as described in stackoverflow http://stackoverflow.com/questions/37810721/linq-join-to-top1?noredirect=1#comment63087615_37810721.
Two Entities: User and Photo. Photo has nullable UserId. So a User can have 0-n Photos.
To select all Users with the first Photo URI I have the following code.
var users = _context.Users.Select( x => new { Name= x.Name, PhotoUri= x.Photos.Select( c => c.Uri ).FirstOrDefault() } );
The SQL I would expect is this:
SELECT User.Name, Photo.Uri FROM User LEFT OUTER JOIN Photo ON Photo.Id = ( SELECT TOP 1 Id FROM Photo WHERE UserId = User.Id )
However EF is generating one SELECT of Users followed by multiple SELECTs on Photos, one for each User record.
The same occurs with the following code variation:
var users = _context.Users.Select( x => new { Name= x.Name, PhotoUri= x.Photos.FirstOrDefault().Uri } );
Is this what I should expect?
The text was updated successfully, but these errors were encountered:
Looks like #4007
Sorry, something went wrong.
@anpete yes quite possibly.
Closing as dupe
No branches or pull requests
Using EF Core RC2.
Issue as described in stackoverflow http://stackoverflow.com/questions/37810721/linq-join-to-top1?noredirect=1#comment63087615_37810721.
Two Entities: User and Photo. Photo has nullable UserId. So a User can have 0-n Photos.
To select all Users with the first Photo URI I have the following code.
The SQL I would expect is this:
However EF is generating one SELECT of Users followed by multiple SELECTs on Photos, one for each User record.
The same occurs with the following code variation:
Is this what I should expect?
The text was updated successfully, but these errors were encountered: