Upgrade to use Specification 4.0.0 (#444)
This commit is contained in:
@@ -3,16 +3,20 @@ using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
|
||||
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
|
||||
{
|
||||
public sealed class BasketWithItemsSpecification : BaseSpecification<Basket>
|
||||
public sealed class BasketWithItemsSpecification : Specification<Basket>
|
||||
{
|
||||
public BasketWithItemsSpecification(int basketId) : base(b => b.Id == basketId)
|
||||
public BasketWithItemsSpecification(int basketId)
|
||||
{
|
||||
AddInclude(b => b.Items);
|
||||
Query
|
||||
.Where(b => b.Id == basketId)
|
||||
.Include(b => b.Items);
|
||||
}
|
||||
|
||||
public BasketWithItemsSpecification(string buyerId) : base(b => b.BuyerId == buyerId)
|
||||
public BasketWithItemsSpecification(string buyerId)
|
||||
{
|
||||
AddInclude(b => b.Items);
|
||||
Query
|
||||
.Where(b => b.BuyerId == buyerId)
|
||||
.Include(b => b.Items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,15 @@ using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
|
||||
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
|
||||
{
|
||||
public class CatalogFilterPaginatedSpecification : BaseSpecification<CatalogItem>
|
||||
public class CatalogFilterPaginatedSpecification : Specification<CatalogItem>
|
||||
{
|
||||
public CatalogFilterPaginatedSpecification(int skip, int take, int? brandId, int? typeId)
|
||||
: base(i => (!brandId.HasValue || i.CatalogBrandId == brandId) &&
|
||||
(!typeId.HasValue || i.CatalogTypeId == typeId))
|
||||
: base()
|
||||
{
|
||||
ApplyPaging(skip, take);
|
||||
Query
|
||||
.Where(i => (!brandId.HasValue || i.CatalogBrandId == brandId) &&
|
||||
(!typeId.HasValue || i.CatalogTypeId == typeId))
|
||||
.Paginate(skip, take);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
|
||||
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
|
||||
{
|
||||
|
||||
public class CatalogFilterSpecification : BaseSpecification<CatalogItem>
|
||||
public class CatalogFilterSpecification : Specification<CatalogItem>
|
||||
{
|
||||
public CatalogFilterSpecification(int? brandId, int? typeId)
|
||||
: base(i => (!brandId.HasValue || i.CatalogBrandId == brandId) &&
|
||||
(!typeId.HasValue || i.CatalogTypeId == typeId))
|
||||
{
|
||||
Query.Where(i => (!brandId.HasValue || i.CatalogBrandId == brandId) &&
|
||||
(!typeId.HasValue || i.CatalogTypeId == typeId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ using System.Linq;
|
||||
|
||||
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
|
||||
{
|
||||
public class CatalogItemsSpecification : BaseSpecification<CatalogItem>
|
||||
public class CatalogItemsSpecification : Specification<CatalogItem>
|
||||
{
|
||||
public CatalogItemsSpecification(params int[] ids) : base(c => ids.Contains(c.Id))
|
||||
public CatalogItemsSpecification(params int[] ids)
|
||||
{
|
||||
|
||||
Query.Where(c => ids.Contains(c.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
using Ardalis.Specification;
|
||||
using Ardalis.Specification.QueryExtensions.Include;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
|
||||
|
||||
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
|
||||
{
|
||||
public class CustomerOrdersWithItemsSpecification : BaseSpecification<Order>
|
||||
public class CustomerOrdersWithItemsSpecification : Specification<Order>
|
||||
{
|
||||
public CustomerOrdersWithItemsSpecification(string buyerId)
|
||||
: base(o => o.BuyerId == buyerId)
|
||||
{
|
||||
AddIncludes(query => query.Include(o => o.OrderItems)
|
||||
.ThenInclude(i => i.ItemOrdered));
|
||||
Query.Where(o => o.BuyerId == buyerId)
|
||||
.Include(o => o.OrderItems)
|
||||
.ThenInclude(i => i.ItemOrdered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user