Select product variants in a category

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