I want to create a List of the type ProductProperty.
I have the following code:
var product = from items in Product.All().Where(x => x.ProductDefinition.Name == "Subscription") select items;
Product[] products = product.ToArray();
List<ProductProperty> propList;
Now I want to add the ProductProperties of that ProductDefinition into the propList.
I have tried the following Query: var property = from props in ProductProperty.Product.All().Where(x => x.ProductDefinition.Name == Subscription") select props;
But it gives the following error: An object reference is required for the non-static field, method, or property 'UCommerce.EntitiesV2.ProductProperty.Product.get'
If I do the following, I get the List that I want, but that is not effecient, because it creates a new list on each iteration of the loop: for(int i = 0; i < products.Length ; i++) { propList = products[i].ProductProperties.ToList(); //action with the list }
I think it's simple what I want, and I did my research, but I couldn't find anything.
I took the liberty of moving your question into the uCommerce section since the above is not Umbraco specific. I think by moving it to the uCommerce space you have bigger chance that the guys behind the uCommerce package sees your question and can provide your help, or that people that uses the uCommerce package can help you.
Query ProductProperty by ProductDefinition
Hello guys,
I'm using Ucommerce in Umbraco 6.
I want to create a List of the type ProductProperty.
I have the following code:
var product = from items in Product.All().Where(x => x.ProductDefinition.Name == "Subscription")
select items;
Product[] products = product.ToArray();
List<ProductProperty> propList;
Now I want to add the ProductProperties of that ProductDefinition into the propList.
I have tried the following Query:
var property = from props in ProductProperty.Product.All().Where(x => x.ProductDefinition.Name == Subscription")
select props;
But it gives the following error:
An object reference is required for the non-static field, method, or property 'UCommerce.EntitiesV2.ProductProperty.Product.get'
If I do the following, I get the List that I want, but that is not effecient, because it creates a new list on each iteration of the loop:
for(int i = 0; i < products.Length ; i++)
{
propList = products[i].ProductProperties.ToList();
//action with the list
}
I think it's simple what I want, and I did my research, but I couldn't find anything.
Thank you in advance, and Happy New Year to All
Hi Gonçalo,
I took the liberty of moving your question into the uCommerce section since the above is not Umbraco specific. I think by moving it to the uCommerce space you have bigger chance that the guys behind the uCommerce package sees your question and can provide your help, or that people that uses the uCommerce package can help you.
/Dennis
Hi, i think you should use:
var properties = ProductProperty
.All()
.Where(x => x.ProductDefinitionField.ProductDefinition.Name == "Subscription")
.ToList();
is working on a reply...