Copied to clipboard

Flag this post as spam?

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


  • Sean Dooley 289 posts 528 karma points
    Nov 02, 2011 @ 13:15
    Sean Dooley
    0

    Unable to cast object of type 'umbraco.MacroEngines.DynamicXml' to type 'TeaCommerce.Data.Order

    Pulling order data back as follows

    umbraco.MacroEngines.DynamicXml finalizedOrders = @Library.ToDynamicXml(TeaCommerce.Library.GetFinalizedOrdersXml());

    Then trying to iterate over the orders and cast each order as a TeaCommerce.Data.Order but receiving the following error

    @foreach (Order order in finalizedOrders) {

    Unable to cast object of type 'umbraco.MacroEngines.DynamicXml' to type 'TeaCommerce.Data.Order

    I can cast the finalizedOrders as a var and each item as a var (as indicated below) but wondering if it is possible to cast as a TeaCommerce.Data.Order instead.

    umbraco.MacroEngines.DynamicXml finalizedOrders = @Library.ToDynamicXml(TeaCommerce.Library.GetFinalizedOrdersXml());

    @foreach (var order in finalizedOrders) {

    Any ideas?

  • Anders Burla 2560 posts 8256 karma points
    Nov 02, 2011 @ 13:39
    Anders Burla
    0

    Hi Sean

    The finalized orders you get from the .NET API is pure XML as to performance - so thats why you cant cast it to an Order object. Im sorry to say that this part of the API cant return Order objects. Its a thing that will definitely work for the Tea Commerce version for Umbraco 5 as its more Razor based - but at the time we started developing Tea Commerce - Razor wasent that big of a thing in umbraco. Can you still implement your desired functionality?

    Kind regards
    Anders

  • Sean Dooley 289 posts 528 karma points
    Nov 02, 2011 @ 13:50
    Sean Dooley
    0

    Hi Anders

    I can still implement the desired functionality without casting it as an Order. Being able to cast it as an Order enabled the intellisense.

    Looking forward to the Umbraco 5 version.

    Thanks

    Sean

  • Sean Dooley 289 posts 528 karma points
    Nov 02, 2011 @ 13:57
    Sean Dooley
    0

    *** Update ***

    Have amended the code as shown below, which enables the intellisense

    var finalizedOrders = @Library.ToDynamicXml(TeaCommerce.Library.GetFinalizedOrdersXml());

    <ul>
    @foreach (var o in finalizedOrders) {
    Order order = Order.GetOrder(long.Parse(o.id));
    @order.Email
    }
    </ul>

  • Anders Burla 2560 posts 8256 karma points
    Nov 02, 2011 @ 13:59
    Anders Burla
    0

    Perfect - thanks for the update! And yes we hope the umbraco 5 version will be even better than the current version - but takes times to write such a big program like Tea Commerce - but we love to do it :)

Please Sign in or register to post replies

Write your reply to:

Draft