Esempio n. 1
0
        public IncPaginatedResult <TEntity> Paginated <TEntity>(PaginatedSpecification paginatedSpecification, OrderSpecification <TEntity> orderSpecification = null, Specification <TEntity> whereSpecification = null, FetchSpecification <TEntity> fetchSpecification = null) where TEntity : class, IEntity
        {
            int totalCount     = GetQuery(null, whereSpecification, null, null).Count();
            var paginatedItems = GetQuery(orderSpecification, whereSpecification, fetchSpecification, paginatedSpecification).ToList();

            return(new IncPaginatedResult <TEntity>(paginatedItems, totalCount));
        }
 public IncPaginatedResult <TEntity> Paginated <TEntity>(PaginatedSpecification paginatedSpecification, OrderSpecification <TEntity> orderSpecification = null, Specification <TEntity> whereSpecification = null, FetchSpecification <TEntity> fetchSpecification = null) where TEntity : class, IEntity, new()
 {
     return(session.Set <TEntity>().Paginated(orderSpecification, whereSpecification, fetchSpecification, paginatedSpecification));
 }
 public IQueryable <TEntity> Query <TEntity>(OrderSpecification <TEntity> orderSpecification = null, Specification <TEntity> whereSpecification = null, FetchSpecification <TEntity> fetchSpecification = null, PaginatedSpecification paginatedSpecification = null) where TEntity : class, IEntity, new()
 {
     return(session.Set <TEntity>().Query(orderSpecification, whereSpecification, fetchSpecification, paginatedSpecification));
 }
Esempio n. 4
0
        IQueryable <TEntity> GetQuery <TEntity>(OrderSpecification <TEntity> orderSpecification, Specification <TEntity> whereSpecification, FetchSpecification <TEntity> fetchSpecification, PaginatedSpecification paginatedSpecification) where TEntity : class, IEntity
        {
            var source = this.session.Value.Query <TEntity>();

            if (whereSpecification != null && whereSpecification.IsSatisfiedBy() != null)
            {
                source = source.Where(whereSpecification.IsSatisfiedBy());
            }

            if (orderSpecification != null)
            {
                var order = new AdHocOrderSpecification <TEntity>();
                orderSpecification.SortedBy()(order);
                source = order.applies.Aggregate(source, (current, apply) => apply(current));
            }

            if (paginatedSpecification != null)
            {
                source = source.Page(paginatedSpecification.CurrentPage, paginatedSpecification.PageSize);
            }

            if (fetchSpecification != null)
            {
                var fetch = new AdHocFetchSpecification <TEntity>();
                fetchSpecification.FetchedBy()(fetch);
                source = fetch.applies.Aggregate(source, (current, apply) => apply(current));
            }

            return(source);
        }
 public IncPaginatedResult <TEntity> Paginated <TEntity>(PaginatedSpecification paginatedSpecification, OrderSpecification <TEntity> orderSpecification = null, Specification <TEntity> whereSpecification = null, FetchSpecification <TEntity> fetchSpecification = null) where TEntity : class, IEntity, new()
 {
     return(GetCollection <TEntity>()
            .AsQueryable <TEntity>()
            .Paginated(orderSpecification, whereSpecification, fetchSpecification, paginatedSpecification));
 }
        public static IQueryable <TEntity> Query <TEntity>(this IQueryable <TEntity> source, OrderSpecification <TEntity> orderSpecification, Specification <TEntity> whereSpecification, FetchSpecification <TEntity> fetchSpecification, PaginatedSpecification paginatedSpecification) where TEntity : class, IEntity
        {
            if (whereSpecification.With(r => r.IsSatisfiedBy()) != null)
            {
                source = source.Where(whereSpecification.IsSatisfiedBy());
            }

            if (orderSpecification != null)
            {
                var order = new AdHocOrderSpecification <TEntity>();
                orderSpecification.SortedBy()(order);
                source = order.applies.Aggregate(source, (current, apply) => apply(current));
            }

            if (paginatedSpecification != null)
            {
                source = source.Page(paginatedSpecification.CurrentPage, paginatedSpecification.PageSize);
            }

            if (fetchSpecification != null)
            {
                AdHocFetchSpecificationBase <TEntity> fetch = null;
                //string fullName = source.Provider.GetType().FullName;
                //if (fullName.EqualsWithInvariant("NHibernate.Linq.DefaultQueryProvider"))
                //    fetch = new AdHocFetchNhibernateSpecification<TEntity>();
                //else
                //if (fullName.EqualsWithInvariant("System.Data.Entity.Internal.Linq.DbQueryProvider"))
                fetch = new AdHocFetchEFSpecification <TEntity>();
                //else if (fullName.Contains("Raven.Client.Linq.RavenQueryProvider"))
                //    fetch = new AdHocFetchRavenDbSpecification<TEntity>();

                //if (fetch != null)
                //{
                fetchSpecification.FetchedBy()(fetch);
                source = fetch.applies.Aggregate(source, (current, apply) => apply(current));
                //}
            }

            return(source);
        }
        public static IncPaginatedResult <TEntity> Paginated <TEntity>(this IQueryable <TEntity> source, OrderSpecification <TEntity> orderSpecification, Specification <TEntity> whereSpecification, FetchSpecification <TEntity> fetchSpecification, PaginatedSpecification paginatedSpecification) where TEntity : class, IEntity
        {
            int totalCount     = source.Query(null, whereSpecification, null, null).Count();
            var paginatedItems = source.Query(orderSpecification, whereSpecification, fetchSpecification, paginatedSpecification).ToList();

            return(new IncPaginatedResult <TEntity>(paginatedItems, totalCount));
        }