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); }
////ncrunch: no coverage end protected bool Equals(AdHocFetchSpecification <TEntity> other) { if (this.expressions.Count != other.expressions.Count) { Console.WriteLine(SpecificationMessageRes.AdHocFetchSpecification_Equal_diffrent_count_expressions.F(this.expressions.Count, other.expressions.Count)); return(false); } for (int i = 0; i < this.expressions.Count; i++) { if (!this.expressions[i].IsExpressionEqual(other.expressions[i])) { Console.WriteLine(SpecificationMessageRes.AdHocFetchSpecification_Equal_diffrent_expressions.F(this.expressions[i], other.expressions[i])); return(false); } } return(true); }
protected bool Equals(FetchSpecification <TEntity> other) { ////ncrunch: no coverage start if (!this.IsReferenceEquals(other)) { return(false); } ////ncrunch: no coverage end /// var fetchLeft = new AdHocFetchSpecification <TEntity>(); FetchedBy()(fetchLeft); var fetchRight = new AdHocFetchSpecification <TEntity>(); other.FetchedBy()(fetchRight); return(fetchLeft.Equals(fetchRight)); }