Asp.net Mvc 2: Repository, Paging, and Filtering how to?
Posted
by Dr. Zim
on Stack Overflow
See other posts from Stack Overflow
or by Dr. Zim
Published on 2010-03-22T02:46:06Z
Indexed on
2010/03/22
2:51 UTC
Read the original article
Hit count: 714
It makes sense to pass a filter object to the repository so it can limit what records return:
var myFilterObject = myFilterFactory.GetBlank();
myFilterObject.AddFilter( new Filter { "transmission", "eq", "Automatic"} );
var myCars = myRepository.GetCars(myfilterObject);
Key question: how would you implement paging and where? Any links on how to return a LazyList from a Repository as it would apply here? Would this be part of the filter object? Something like:
myFilterObject.AddFilter( new Filter { "StartAtRecord", "eq", "45"} );
myFilterObject.AddFilter( new Filter { "GetQuantity", "eq", "15"} );
var myCars = myRepository.GetCars(myfilterObject);
I assume the repository must implement filtering, otherwise you would get all records.
© Stack Overflow or respective owner