Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Gonçalo Assunção 39 posts 68 karma points
    Dec 30, 2014 @ 19:16
    Gonçalo Assunção
    0

    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

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 30, 2014 @ 20:39
    Dennis Aaen
    0

    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

  • Morten Skjoldager 440 posts 1499 karma points
    Jan 13, 2015 @ 14:16
    Morten Skjoldager
    0

    Hi, i think you should use:

    var properties = ProductProperty

    .All()

    .Where(x => x.ProductDefinitionField.ProductDefinition.Name == "Subscription")

    .ToList();

     

Please Sign in or register to post replies

Write your reply to:

Draft