score:2

Accepted answer

I'm not sure how much I can guess correctly here, but let's give it a try.

First, let's assume, we may have this input:

var listOfOrders = new List<OrderItem>
{
    new OrderItem
    {
        Id = 1,
        OrderData = @"{
                        ""orderLine1"": ""line1"",
                        ""orderLine2"": ""line2"",
                    }",
        OrderEvent = "Start",
        OrderNo = 111
    },
    new OrderItem
    {
        Id         = 1,
        OrderData = @"{
                        ""orderLine1"": ""line1"",
                        ""orderLine2"": ""line2"",
                    }",
        OrderEvent = "Start",
        OrderNo    = 111
    },
    new OrderItem
    {
        Id         = 2,
        OrderData = @"{
                        ""orderLine1"": ""line1"",
                        ""orderLine2"": ""line2"",
                    }",
        OrderEvent = "Start",
        OrderNo    = 121
    }
};

Now, I'm assuming you may want to group these items by OrderNo and get a collection of items with the similar Order Number:

var collection = listOfOrders
    .GroupBy(l => l.OrderNo)
    .Select(group => new
    {
        Number = group.Key, // OrderNo
        OrderEvent = group.Select(elm => new
        {
            OrderEvent = elm.OrderEvent,
            OrderData = JObject.Parse(elm.OrderData) // assume we want to parse a
                                                     // JSON but this can be other logic
        })
    }).ToList();

Related Articles