I have several grid interfaces with some search/fitler functionality… The number of filter is ‘randon’ …
Example, in my Color UI I have just onde filter: Name … And my method of paging/search is :
public IEnumerable<Color> Search(string nameSearch, string order, int pageSize, int pageIndex, bool ascending, out int totalCount)
{
var query = Session.QueryOver<Color>();
var rowCountQuery = query.ToRowCountQuery();
query.Where(color => color.Name.IsLike(nameSearch, MatchMode.Anywhere));
if (ascending)
query.OrderBy(x => x.Name).Asc();
else
query.OrderBy(x => x.Name).Desc();
query.Take(__pageSize).Skip((pageIndex) * pageSize)
.Future();
totalCount = rowCountQuery.FutureValue<int>().Value;
return query.List();
}
It´s working fine so far… But I have other several UI with same functionality and I´d like to create a generic serach function…
Is there any like that already implemented?
Any help would be appreciated!
You might want to think about creating an object to hold the the paging parameters and also validating the order column, but you could create a simple paging function like this…