1

Hi guys I need to rewrite the sql query below using Linq to entity. Unfortunately I don't have a lot of experience of using Linq. Please help me

 With TempTableName AS 
(SELECT [ColumnName],  
        [ColumnName2], 
        [ColumnName3], 
        [ColumnName4], 
 ROW_NUMBER() OVER (order by ColumnName desc) as RowNumber from TableName )
         SELECT 
        [ColumnName],  
        [ColumnName2], 
        [ColumnName3], 
        [ColumnName4]
FROM TempTableName  WHERE ROWNUMBER 
Between 10 and 100 

1 Answer 1

3
(from t in dbContext.TableName
order by ColumnName descending
select new { ColumnName = t.ColumnName, ColumnName2 = t.ColumnName2 /* ... */  })
.Skip(9)
.Take(91)

If you want to work all the columns from TableName, you can also use select t, this. Probably easier to use, but this will fetch all columns, and it is not clear from your question if that is what you want.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.