小编HGR*_*ser的帖子

LINQ查询语法中的SQL ROW_NUMBER()

我有这个查询,我希望用Linq替换为查询语法:

select 
    ii.Id, ii.Name as Supplier,
    qi.Price1, qi.Price2, qi.Price3,
    case when qi.price1 is null then NULL else ROW_NUMBER() OVER(ORDER BY isNull(qi.price1,1000000) ASC) end AS Price1Order,    
    case when qi.price2 is null then NULL else ROW_NUMBER() OVER(ORDER BY isNull(qi.price2,1000000) ASC) end AS Price2Order,    
    case when qi.price3 is null then NULL else ROW_NUMBER() OVER(ORDER BY isNull(qi.price3,1000000) ASC) end AS Price3Order
From dbo.InquiryItems ii
left join dbo.quoteItems qi on ii.Id = qi.QuoteItem_InquiryItem
Run Code Online (Sandbox Code Playgroud)

SQL查询结果:

Id      Supplier        Price1  Price2  Price3  Price1Order Price2Order Price3Order
1655    Supplier 2 …
Run Code Online (Sandbox Code Playgroud)

c# linq sql-server

5
推荐指数
1
解决办法
454
查看次数

标签 统计

c# ×1

linq ×1

sql-server ×1