Quantcast
Channel: Tech World » LINQ
Viewing all articles
Browse latest Browse all 2

ROW_NUMBER() in LINQ 2 SQL

0
0

Last week was quite simple and went without trouble  , and just before I start enjoying my weekends – stuck in to in issue of getting ROW_NUMBER() (as we are doing in sandard SQL Query !

Finally come-up with sort and sweet code!

var items = context.ItemMasters.AsEnumerable()

.Select((u, index) =>  new ItemDetail

{    ItemId = u.ItemId,

ItemName = u.ItemName,

IsActive = (bool)u.IsActive,

Count = index + initialRow + 1

}).Skip(initialRow).Take(finalRow).ToList();

Please post comment if any other better solutions is possible for the same.

Thanks

Happy Coding !

 


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images