-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
SqlException: "No column name was specified for column 1 of 't'" on IQueryable.Count() with Skip and Take #30239
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
area-System.Linq.Expressions |
Tagging subscribers to this area: @cston Issue DetailsDescriptionRetrieving the number of records via Count() in a IQueryable with Skip() and Take() results in an exception: Reproduction Steps
Expected behaviorFirst Count() results in SQL statement:
expected: returns rowcount Second Count() results in SQL statement:
expected: returns 1000 Actual behaviorSecond Count() results in SQL statement:
and throws a sqlexception: "No column name was specified for column 1 of 't'" Regression?In .net 6.0 this works, but while moving to .net 7.0 we got this exception. Known Workarounds
Configuration.net 7.0 Other informationThe problem is, there is no column name in the query. By adding "AS column1" in the select statement the query will work.
|
Thanks @hvkooten, I'll investigate. |
@ajcvickers, should this issue be assigned to area-System.Data? From a simple test, it looks like the |
Hi @cston,
So, there definitive is a change somewhere ;-) |
looks like a dupe of #29667, which is now fixed in main and approved for 7.0.4 patch |
Description
Retrieving the number of records via Count() in a IQueryable with Skip() and Take() results in an exception:
Reproduction Steps
Expected behavior
First Count() results in SQL statement:
expected: returns rowcount
Second Count() results in SQL statement:
expected: returns 1000
Actual behavior
Second Count() results in SQL statement:
and throws a sqlexception: "No column name was specified for column 1 of 't'"
Regression?
In .net 6.0 this works, but while moving to .net 7.0 we got this exception.
Known Workarounds
query.ToList().count;
But this will materialize the query and send all data to memory
Configuration
.net 7.0
development: Windows
production: Azure
Other information
The problem is, there is no column name in the query. By adding "AS column1" in the select statement the query will work.
The text was updated successfully, but these errors were encountered: