# Friday, May 28, 2010

One of the questions I’ve come across a couple of times with uCommerce is using the LINQ API to query products by custom properties added to a product definition.

Here’s how:

var q = from product in Product.All()
  where product.ProductProperties.Where(property => 
    (property.ProductDefinitionField.Name == "MyProperty" && property.Value == "MyPropertyValue") 
    || (property.ProductDefinitionField.Name == "MyOtherProperty" && property.Value == "MyotherPropertyValue")).Count() == 2
    && product.ParentProductId == null
  select product;
Comments are closed.