Rewrite SQL query using Linq to entity
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 WHER开发者_运维技巧E ROWNUMBER
Between 10 and 100
(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.
精彩评论