FindAll and Count with Paging

33 views
Skip to first unread message

khcha...@gmail.com

unread,
Oct 30, 2014, 3:22:44 AM10/30/14
to sharpre...@googlegroups.com
Hi folks,

I find myself doing FindAll or GetAll with Count and Pagination often.
at the moment i always do the following:

[code]
IRepository<XXX> repo;

int total = repo.Count(SomeQuery);
var result = repo.FindAll(SomeQuery, SomePagingOptions);

OR

int total = repo.Count();
var result = repo.GetAll(SomePagingOptions);

// note: if i do result.Count() i would only get count for the current page instead of the total count i wanted
[/code]


So my Questions:

1. does SharpRepository issue 2 queries to the underlying data source? one for Count, one for the FindAll or GetAll

2. if it does issue 2 queries, is there a way to optimize so that it does those in one go? Is there a better way?


Thanks in advance.

Omar Piani

unread,
Jul 15, 2016, 4:10:40 AM7/15/16
to SharpRepository, khcha...@gmail.com
hem.. sorry, it's a bit late..

SomePagingOptions.TotalItems will count all items after a pagination.

Post on GitHub!
Reply all
Reply to author
Forward
0 new messages