Row_Number is always 1 when selected after first query
See original GitHub issueIn the below query, when i to a ToList()
after first select i am getting correct row index with each record, but when i try to get the result based on where filter i am always getting 1 in return value.
await repository.Query().OrderBy(t => t.DateCreated)
.Where(pb => pb.IsActive == true && pb.SiteId == currentBlogPost.SiteId && pb.BlogPostTypeId == currentBlogPost.BlogPostTypeId)
.Select(x => new BlogMinimalInfo { Index = Sql.Ext.RowNumber().Over().OrderBy(x.DateCreated).ToValue(),Id=x.Id })
.ToLinqToDB()
.Where(pb => pb.Id == currentBlogPost.Id)
.Select(pb => pb.Index) ==> this always comes 1 but should be different based on each Id
.FirstOrDefaultAsyncLinqToDB();
i need this query to work so i can select prev & next record of current row which is guid Ids. And Enumeration will be bad once database starts growng.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
row number always return 1 for each row in sql server
The above query always returns rownumber 1 for each row. When I use the select statement outside, its problem. Otherwise if I remove...
Read more >Overview of the SQL ROW_NUMBER function
ROW_NUMBER adds a unique incrementing number to the results grid. The order, in which the row numbers are applied, is determined by the...
Read more >Is SELECT ROW_NUMBER() guaranteed to return results ...
I was expecting the row number to be assigned to the rows but I was not expecting the rows to come back sorted...
Read more >Rownum - Ask TOM - Oracle
1. I have a table called a where I have more than one row. When I put a query "SELECT * FROM A...
Read more >ROW_NUMBER (Transact-SQL) - SQL Server
ROW_NUMBER is a temporary value calculated when the query is run. To persist numbers in a table, see IDENTITY Property and SEQUENCE. Transact- ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes it is a bug. Try to put
AsSubQuery()
exactly beforeToLinqToDB()
@sdanyliv can you look into this?