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

Query: Projected values can be the wrong type #6337

Closed
ajcvickers opened this issue Aug 16, 2016 · 1 comment
Closed

Query: Projected values can be the wrong type #6337

ajcvickers opened this issue Aug 16, 2016 · 1 comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@ajcvickers
Copy link
Contributor

Consider this query:

var values = context.Drivers.AsNoTracking()
    .Where(e => e.Id == larry.Id)
    .Select(e => new object[] { e.Id, e.Name, e.Poles })
    .FirstOrDefault();

The types of properties Id, Name, and Poles are int, string, int respectively. So the expectation is that the projected values in the array would be of those types. However, on SQLite, the values are of type long, string, long. That is, the types are the defaults from the store and not the requested types. I expect the same issue would exist on SQL Server in places where the type is relevant.

Note that if I let LINQ to Objects to do the projection:

var values = context.Drivers.AsNoTracking()
    .Where(e => e.Id == larry.Id)
    .ToList()
    .Select(e => new object[] { e.Id, e.Name, e.Poles })
    .FirstOrDefault();

then the types in the array are int, string, int, as expected.

However, in the real code I can't use LINQ to Objects for this because I am using EF.Property calls to project shadow values.

This bug currently prevents GetDatabaseValues from working on SQLite.

@divega divega added this to the 1.1.0 milestone Aug 17, 2016
ajcvickers added a commit that referenced this issue Aug 17, 2016
Issue #1200

Pretty much the same design as EF6. Exposed full property metadata instead of names since we now have nice metadata. Tests were ported from EF6. Not fully functional, especially on SqLite, until #6337 is fixed.
ajcvickers added a commit that referenced this issue Aug 19, 2016
Issue #1200

Pretty much the same design as EF6. Exposed full property metadata instead of names since we now have nice metadata. Tests were ported from EF6. Not fully functional, especially on SqLite, until #6337 is fixed.
@ajcvickers
Copy link
Contributor Author

Poaching this.

@ajcvickers ajcvickers assigned ajcvickers and unassigned smitpatel Aug 20, 2016
ajcvickers added a commit that referenced this issue Aug 20, 2016
Issue #6337

The expression tree has converts in it to box the returned values. But this means we always ask for object from the reader. Therefore, use the value inside the convert when asking for the value from the data reader.
ajcvickers added a commit that referenced this issue Aug 22, 2016
Issue #6337

The expression tree has converts in it to box the returned values. But this means we always ask for object from the reader. Therefore, use the value inside the convert when asking for the value from the data reader.
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 22, 2016
@ajcvickers ajcvickers modified the milestones: 1.1.0-preview1, 1.1.0 Oct 15, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

3 participants