开发者

Extension Method Limiting The Number Of Linq Results?

开发者 https://www.devze.com 2023-02-14 11:54 出处:网络
How can I limit the number of results from an e开发者_StackOverflowxtension method on a linq query?

How can I limit the number of results from an e开发者_StackOverflowxtension method on a linq query?

var results = db.table.where(a=>a.Id > 500).Limit(10)???


Use IEnumerable.Take

var results = db.table.where(a=>a.Id > 500).Take(10)

Side note
If you want to implement paging there is also IEnumerable.Skip that can be used to "fast forward" a number of records. Then use like this

.Skip(pageNo * pageSize).Take(pageSize)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号