Select product variants in a category

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 11 años
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
Hace 11 años
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;
Hace 11 años
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);
Hace 11 años
Even better!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.