Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm in OSX right now so I can't test the solution, but I'd probably add a property to my order class to calculate the group. I feel like your order would reasonably be concerned with this. So, you could have something like this:</p> <pre><code>class order { Guid employeeId; DateTime time; public int Group { get { return /* check hours of day to group /} } } </code></pre> <p>Then, it should be as easy as <code>orders.GroupBy(o =&gt; o.Group)</code>;</p> <p>If you don't feel like your order should know about the groups, you could make another method where you feel it's more important to define the group. Then you could still say <code>orders.GroupBy(o =&gt; GetGroupNumber(o))</code>.</p> <p>If you still need help next time I'm in Windows, I'll write a snippet for you.</p> <p><strong>EDIT:</strong> </p> <p>I've noticed several of the other answers to this question recommend executing a Where or a Skip-Take strategy (with the overhead of a sort) on the original list for each child list you want to create. </p> <p>My concern is that there is a performance detriment on large sets. For example, the four .Where evaluations will execute the comparisons on all of your objects four times despite the fact that the groups are mutually exclusive.</p> <p>I don't know how many data you have, but for your sake I hope it's a LOT of orders :). In any event, I'd probably try to do the grouping and comparisons in one iteration like I recommended. If you don't like that solution, I'd recommend you iterate over the list yourself and built your sets without linq to objects.</p> <p>Just my two cents.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload