Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created November 9, 2009 20:36
Show Gist options
  • Save jfromaniello/230259 to your computer and use it in GitHub Desktop.
Save jfromaniello/230259 to your computer and use it in GitHub Desktop.
public interface IPaginatorModel<TEntity> where TEntity : Entity
{
ICollection<TEntity> GetPage(int pageSize,
int pageNumber,
Expression<Func<TEntity, bool>> filterFunction,
Func<TEntity, object> sortFunction);
int GetPageCount(int pageSize,
Expression<Func<TEntity, bool>> filterFunction);
}
//The implementation:
[PersistenceConversational(MethodsIncludeMode = MethodsIncludeMode.Implicit)]
public class PaginatorModel<TEntidad> : IPaginatorModel<TEntidad> where TEntidad : Entity
{
private readonly IDaoReadOnly<TEntidad> _dao;
public ModeloListar(IDaoFactory daoFactory)
{
_dao = daoFactory.GetDaoReadOnlyOf<TEntidad>();
}
#region IPaginatorModel<TEntidad> Members
[PersistenceConversation(ConversationEndMode = EndMode.End)]
public virtual ICollection<TEntidad> GetPage(
int pageSize, int pageNumber,
Expression<Func<TEntidad, bool>> filterFunction,
Func<TEntidad, object> sortFunction)
{
return _dao
.Retrieve(predicado)
.OrderBy(sortFunction)
.Skip(pageSize * pageNumber)
.Take(pageSize).ToList();
}
[PersistenceConversation(ConversationEndMode = EndMode.End)]
public virtual int GetPageSize(
int pageSize,
Expression<Func<TEntidad, bool>> filterFunction)
{
//balbalblalbal
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment