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

Projection and redundant order by with Navigation propery #8238

Closed
tomerpeled opened this issue Apr 20, 2017 · 2 comments
Closed

Projection and redundant order by with Navigation propery #8238

tomerpeled opened this issue Apr 20, 2017 · 2 comments

Comments

@tomerpeled
Copy link

tomerpeled commented Apr 20, 2017

When using navigation property the generated sql query ignores the projection requested and bring all columns (for both tables).
Also an order by clause is added to the query - but I guess this maybe relates to #6861 right?

Example:

Models:

public class Player
{        
        public string PlayerId { get; set; }

        public string Nickname { get; set; }

        public string CountryId { get; set; }
        public Country County { get; set; }
}

public class Country
{
        public string CountryId { get; set; }
        public string Name { get; set; }
}

The query::

var playerInfo =
                    (from p in ctx.Players
                        where p.PlayerId == "123"
                        select new
                        {
                            Player = p.PlayerId,
                            Name = p.County.Name
                        })
                    .FirstOrDefaultAsync().Result;

The SQL generated:

SELECT p.PlayerId, p.CountryId,  p.Nickname, p_County.CountryId, p_County.Name
FROM Players AS p
LEFT JOIN Countries AS p_County ON p.CountryId = p_County.CountryId
WHERE p.PlayerId = '123'
ORDER BY p.CountryId
LIMIT 1

Is this a known issue?

@maumar
Copy link
Contributor

maumar commented Apr 20, 2017

dupe of #6647

@tomerpeled
Copy link
Author

Thanks

@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