0

I have an OrderBlock object that contain a list of Orders. This list is bound to my datagrid.

The list often contain multiple orders for the same stock, say Microsoft. Some of the orders might be buy others might be sell orders.

I want to group my list based on the Order.Id and Order.Side but I am unsure how to do this?

2 Answers 2

6
var grouped = list.GroupBy(x => new {x.Id, x.Side});
Sign up to request clarification or add additional context in comments.

Comments

6

You can use something like this:

var results = 
    from o in OrderBlock
    group o by new { o.Id, o.Side };

Or in fluent syntax:

var results = OrderBlock.GroupBy(o => new { o.Id, o.Side });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.