I have a LARGE datatable (500k-1m rows), without going into detail this is a requirement as the end user needs/wants to be able to see all of the data. This is on a local server so bandwidth etc are not concerns for me.
I have a DateTime field in the DataTable which I need to group, let me explain what I mean by grouping... It's probably not what you think I mean (from looking at the other questions on here!).
var table = new DataTable();
table.Columns.Add("EventTime", typeof(DateTime));
table.Columns.Add("Result", typeof(String));
table.Columns.Add("ValueOne", typeof(Int32));
table.Columns.Add("ValueTwo", typeof(Int32));
table.Rows.Add("2012-02-06 12:41:45.190", "A", "7", "0");
table.Rows.Add("2012-02-06 12:45:41.190", "B", "3", "89");
table.Rows.Add("2012-02-06 12:59:41.190", "C", "1", "0");
table.Rows.Add("2012-02-06 13:41:41.190", "D", "0", "28");
table.Rows.Add("2012-02-06 17:41:41.190", "E", "0", "37");
table.Rows.Add("2012-02-07 12:41:45.190", "F", "48", "23");
I would expect the above table to be grouped so that I get a sum of the "ValueOne" column, and an average of the "ValueTwo" column. I need the grouping to be a little bit flexible so that I can specify that I want grouping by minutes (only the first and last rows would be grouped, the rest would just provide their values), or by days (all but the last row would be grouped into a single row), etc.
I've tried this a few times but I'm getting no where. My LINQ knowledge isn't great, but I thought I'd be able to do this!
Note: The DataTable is already on the machine for calculations/views which cannot be changed, so saying "Stop being an idiot, filter in SQL!!!" is a valid answer, just useless to me! :-D
Also, in case you missed it in the title, I need this in C# - I'm working with .NET 4.0...
Thanks in advance, assuming you decide to help! :-)