开发者

Extension Method Limiting The Number Of Linq Results?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜