Select product variants in a category

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 Jahre weitere
Does anyone know the linq for selecting all the product variants within a category?

I can select them by iterating each product and then finding the pv for each but was hoping to simplify my code with a simply linq query using joins.

Darren
11 Jahre weitere
Assuming you have Repositories set up for each table:


var query = from pv in _productVariantRepository.Table
                  join pc in _productCategoryRepository.Table on pv.ProductId equals pc.ProductId
                  where pc.CategoryId == categoryId
                  select pv;
11 Jahre weitere
AndyMcKenna wrote:
Assuming you have Repositories set up for each table:


var query = from pv in _productVariantRepository.Table
                  join pc in _productCategoryRepository.Table on pv.ProductId equals pc.ProductId
                  where pc.CategoryId == categoryId
                  select pv;


Thanks Andy. This will come in handy in the future.

I actually ended up using this service which returnes pv's by categoryId - Nice

_productService.SearchProductVariants(categoryId, 0, string.Empty, false, 0, int.MaxValue, false);
11 Jahre weitere
Even better!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.