Copied to clipboard

Flag this post as spam?

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


  • Chris Soto 13 posts 33 karma points
    Apr 02, 2012 @ 14:27
    Chris Soto
    0

    Accessing OrderLine Properties in C#

    Hi Rune, Anders,

    My client would like to export orders as they are placed into their fulfillment system. I am doing this inside a .Net event handler, but seem to have problems accessing the OrderLine Properties.

    I tried using:

    Data.OrderLine ol = order.OrderLines.ElementAt<Data.OrderLine>(i);
    ol.Properties.GetValue<Data.OrderLineProperty>(strAlias).Value.ToString();

    and

    ol.GetValue<Data.OrderLineProperty>(strAlias).Value.ToString()

    This is probably something basic, but what is the correct method/syntax to accessing these values?

    Thanks,

    Chris

  • Doogie Talons 183 posts 318 karma points
    Apr 02, 2012 @ 14:34
    Doogie Talons
    0

    I have just finished a discount thing which I will be posting on line when I can actually describe coherantly how I achieved it with the help of Anders...

    Anders taught me to access the orderline properties thusly using linq

     

     OrderLineProperty checkAVar = orderLine.Properties.FirstOrDefault( i => i.Alias == "quantityOverA" );

                if(checkAVar != null )

                {

                Decimal quantityaV = System.Convert.ToDecimal(orderLine.Properties.First(i => i.Alias == "quantityOverA").Value);

                }

    This is because I was messing about with a price so I converted to a decimal number, the same for a string ect would be..

    String thisVar = orderLine.Properties.First(i => i.Alias == "thisProperty").Value;

    I hope this helps.

    Doogie.

     

  • Chris Soto 13 posts 33 karma points
    Apr 02, 2012 @ 14:52
    Chris Soto
    0

    That seems to have done the trick.

    Thanks very much for your help.

     

    -Chris

  • Doogie Talons 183 posts 318 karma points
    Apr 02, 2012 @ 15:00
    Doogie Talons
    0

    I was stood on Anders shoulders for that one :) I am a bit of a c# noob. I don't fully understand what's going on here..

    (i => i.Alias == "thisProperty")

    I was assured it was Linq, and it works over multiple properties so...

    Cheers

     

  • Anders Burla 2560 posts 8256 karma points
    Apr 02, 2012 @ 15:55
    Anders Burla
    0

    Hi Doogie

    Its LINQ and Lambda expressions - just google it :)

    Glad you could help Chris with his question!

    Kind regards
    Anders

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies