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

@@ -1,10 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Microsoft.eShopWeb.Infrastructure.Data
{
@@ -38,6 +35,11 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
query = query.OrderByDescending(specification.OrderByDescending);
}
if (specification.GroupBy != null)
{
query = query.GroupBy(specification.GroupBy).SelectMany(x => x);
}
// Apply paging if enabled
if (specification.isPagingEnabled)
{