|
|
|
@ -22,19 +22,42 @@ namespace EasyAbp.EShop.Products.Products |
|
|
|
|
|
|
|
public IQueryable<Product> GetQueryable(Guid storeId, Guid categoryId) |
|
|
|
{ |
|
|
|
return from product in DbContext.Products |
|
|
|
join productStore in DbContext.ProductStores on product.Id equals productStore.ProductId |
|
|
|
join productCategory in DbContext.ProductCategories on product.Id equals productCategory.ProductId |
|
|
|
where productStore.StoreId == storeId && productCategory.CategoryId == categoryId |
|
|
|
select product; |
|
|
|
return JoinProductCategories(GetQueryable(storeId), categoryId); |
|
|
|
} |
|
|
|
|
|
|
|
public IQueryable<Product> GetQueryable(Guid storeId) |
|
|
|
{ |
|
|
|
return from product in DbContext.Products |
|
|
|
join productStore in DbContext.ProductStores on product.Id equals productStore.ProductId |
|
|
|
where productStore.StoreId == storeId |
|
|
|
select product; |
|
|
|
return JoinProductStores(GetQueryable(), storeId); |
|
|
|
} |
|
|
|
|
|
|
|
public IQueryable<Product> WithDetails(Guid storeId, Guid categoryId) |
|
|
|
{ |
|
|
|
return JoinProductCategories(WithDetails(storeId), categoryId); |
|
|
|
} |
|
|
|
|
|
|
|
public IQueryable<Product> WithDetails(Guid storeId) |
|
|
|
{ |
|
|
|
return JoinProductStores(WithDetails(), storeId); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual IQueryable<Product> JoinProductStores(IQueryable<Product> queryable, Guid storeId) |
|
|
|
{ |
|
|
|
return queryable.Join( |
|
|
|
DbContext.ProductStores.Where(productStore => productStore.StoreId == storeId), |
|
|
|
product => product.Id, |
|
|
|
productStore => productStore.ProductId, |
|
|
|
(product, productStore) => product |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual IQueryable<Product> JoinProductCategories(IQueryable<Product> queryable, Guid categoryId) |
|
|
|
{ |
|
|
|
return queryable.Join( |
|
|
|
DbContext.ProductCategories.Where(productCategory => productCategory.CategoryId == categoryId), |
|
|
|
product => product.Id, |
|
|
|
productCategory => productCategory.ProductId, |
|
|
|
(product, productCategory) => product |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |