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: Skip with Count always returns 0 #7523

Closed
archanasoni opened this issue Feb 1, 2017 · 1 comment
Closed

Query: Skip with Count always returns 0 #7523

archanasoni opened this issue Feb 1, 2017 · 1 comment
Assignees
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

@archanasoni
Copy link

We are working to have Core support for IBM EntityFramework Provider.
For one of our internal test application, we have to skip few rows and and return remaining total number of rows.
Our query is:
context.ArchTable1.OrderBy(c=>c.Id).Skip(1).Count()

It always returns output:
skip count 0
We have used UseRowNumberForPaging() via optionsBuilder.

The similar Application when we run against SQL Server 2008, we do see same issue.
Generated SQL is:
SELECT [t].[c0]
FROM (
SELECT COUNT(*) AS [c0], ROW_NUMBER() OVER(ORDER BY @@rowcount) AS [RowNumber]
FROM [ArchTable1] AS [a]
) AS [t]
WHERE [t].[RowNumber] > 1

With manual modification in above query, if we run from SQL management Studio it returns the desired output:
SELECT COUNT(*) AS [c0] from
(select ROW_NUMBER() OVER(ORDER BY @@rowcount) AS [RowNumber]
FROM [ArchTable1] AS [a]
) AS [t]
WHERE [t].[RowNumber] > 1

Now questions are:

  1. Though user mentioned OrdeyBy clause, but why it's not reflecting in generated query ?
  2. PushDownSubquery() basically pushes down the current query. How do we inject some new SQL (i.e. select statement to achieve above working query) in between in current selectExpression ?
@smitpatel smitpatel self-assigned this Feb 1, 2017
@rowanmiller rowanmiller added this to the 2.0.0 milestone Feb 1, 2017
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 4, 2017
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 6, 2017
…ated

SQL

- Resolves dotnet#2341
- Resolves dotnet#5085
- Resolves dotnet#5230
- Resolves dotnet#6618
- Resolves dotnet#6647
- Resolves dotnet#6782
- Resolves dotnet#7080
- Resolves dotnet#7220
- Resolves dotnet#7417
- Resolves dotnet#7497
- Resolves dotnet#7523
- Resolves dotnet#7525
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 6, 2017
…ated

SQL

- Resolves dotnet#2341
- Resolves dotnet#5085
- Resolves dotnet#5230
- Resolves dotnet#6618
- Resolves dotnet#6647
- Resolves dotnet#6782
- Resolves dotnet#7080
- Resolves dotnet#7220
- Resolves dotnet#7417
- Resolves dotnet#7497
- Resolves dotnet#7523
- Resolves dotnet#7525
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 6, 2017
…ated

SQL

- Resolves dotnet#2341
- Resolves dotnet#5085
- Resolves dotnet#6618
- Resolves dotnet#6647
- Resolves dotnet#6782
- Resolves dotnet#7080
- Resolves dotnet#7220
- Resolves dotnet#7417
- Resolves dotnet#7497
- Resolves dotnet#7523
- Resolves dotnet#7525
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 6, 2017
…ated

SQL

- Resolves dotnet#2341
- Resolves dotnet#5085
- Resolves dotnet#6618
- Resolves dotnet#6647
- Resolves dotnet#6782
- Resolves dotnet#7080
- Resolves dotnet#7220
- Resolves dotnet#7417
- Resolves dotnet#7497
- Resolves dotnet#7523
- Resolves dotnet#7525
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 7, 2017
…ated

SQL

- Resolves dotnet#2341
- Resolves dotnet#5085
- Resolves dotnet#6618
- Resolves dotnet#6647
- Resolves dotnet#6782
- Resolves dotnet#7080
- Resolves dotnet#7220
- Resolves dotnet#7417
- Resolves dotnet#7497
- Resolves dotnet#7523
- Resolves dotnet#7525
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 9, 2017
…ated

SQL

- Resolves dotnet#2341
- Resolves dotnet#5085
- Resolves dotnet#6618
- Resolves dotnet#6647
- Resolves dotnet#6782
- Resolves dotnet#7080
- Resolves dotnet#7220
- Resolves dotnet#7417
- Resolves dotnet#7497
- Resolves dotnet#7523
- Resolves dotnet#7525
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 9, 2017
tuespetre added a commit to tuespetre/EntityFramework that referenced this issue Feb 10, 2017
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Feb 10, 2017
@ajcvickers ajcvickers changed the title Skip with Count always returns 0 Query: Skip with Count always returns 0 May 9, 2017
@divega divega added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels May 10, 2017
@ajcvickers
Copy link
Contributor

@archanasoni If you are still using RowNumberForPaging, could you please comment on issue #13959 and let us know why?

@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Oct 15, 2022
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

5 participants