Adding a GroupBy specification example

This commit is contained in:
Eric Fleming
2019-04-20 21:49:57 -04:00
parent 1632f7fb75
commit 468df47c22
4 changed files with 14 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
public List<string> IncludeStrings { get; } = new List<string>();
public Expression<Func<T, object>> OrderBy { get; private set; }
public Expression<Func<T, object>> OrderByDescending { get; private set; }
public Expression<Func<T, object>> GroupBy { get; private set; }
public int Take { get; private set; }
public int Skip { get; private set; }
@@ -43,5 +44,11 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
{
OrderByDescending = orderByDescendingExpression;
}
protected virtual void ApplyGroupBy(Expression<Func<T, object>> groupByExpression)
{
GroupBy = groupByExpression;
}
}
}

View File

@@ -9,6 +9,7 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
(!typeId.HasValue || i.CatalogTypeId == typeId))
{
ApplyPaging(skip, take);
ApplyGroupBy(i => new { i.CatalogType });
}
}
}