Remove non-icon basket link from header
Add comments to EF query logic
This commit is contained in:
@@ -43,25 +43,34 @@ namespace Infrastructure.Data
|
|||||||
|
|
||||||
public IEnumerable<T> List(ISpecification<T> spec)
|
public IEnumerable<T> List(ISpecification<T> spec)
|
||||||
{
|
{
|
||||||
|
// fetch a Queryable that includes all expression-based includes
|
||||||
var queryableResultWithIncludes = spec.Includes
|
var queryableResultWithIncludes = spec.Includes
|
||||||
.Aggregate(_dbContext.Set<T>().AsQueryable(),
|
.Aggregate(_dbContext.Set<T>().AsQueryable(),
|
||||||
(current, include) => current.Include(include));
|
(current, include) => current.Include(include));
|
||||||
|
|
||||||
|
// modify the IQueryable to include any string-based include statements
|
||||||
var secondaryResult = spec.IncludeStrings
|
var secondaryResult = spec.IncludeStrings
|
||||||
.Aggregate(queryableResultWithIncludes,
|
.Aggregate(queryableResultWithIncludes,
|
||||||
(current, include) => current.Include(include));
|
(current, include) => current.Include(include));
|
||||||
|
|
||||||
|
// return the result of the query using the specification's criteria expression
|
||||||
return secondaryResult
|
return secondaryResult
|
||||||
.Where(spec.Criteria)
|
.Where(spec.Criteria)
|
||||||
.AsEnumerable();
|
.AsEnumerable();
|
||||||
}
|
}
|
||||||
public async Task<List<T>> ListAsync(ISpecification<T> spec)
|
public async Task<List<T>> ListAsync(ISpecification<T> spec)
|
||||||
{
|
{
|
||||||
|
// fetch a Queryable that includes all expression-based includes
|
||||||
var queryableResultWithIncludes = spec.Includes
|
var queryableResultWithIncludes = spec.Includes
|
||||||
.Aggregate(_dbContext.Set<T>().AsQueryable(),
|
.Aggregate(_dbContext.Set<T>().AsQueryable(),
|
||||||
(current, include) => current.Include(include));
|
(current, include) => current.Include(include));
|
||||||
|
|
||||||
|
// modify the IQueryable to include any string-based include statements
|
||||||
var secondaryResult = spec.IncludeStrings
|
var secondaryResult = spec.IncludeStrings
|
||||||
.Aggregate(queryableResultWithIncludes,
|
.Aggregate(queryableResultWithIncludes,
|
||||||
(current, include) => current.Include(include));
|
(current, include) => current.Include(include));
|
||||||
|
|
||||||
|
// return the result of the query using the specification's criteria expression
|
||||||
return await secondaryResult
|
return await secondaryResult
|
||||||
.Where(spec.Criteria)
|
.Where(spec.Criteria)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|||||||
@@ -33,8 +33,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</section>
|
</section>
|
||||||
@await Html.PartialAsync("_LoginPartial")
|
@await Html.PartialAsync("_LoginPartial")
|
||||||
<section class="col-lg-1 col-md-3 col-xs-6"><a asp-controller="Basket" asp-action="Index">Basket</a></section>
|
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in New Issue
Block a user