I have table with below fields,
table Shows,
Id Name Time
1 A 7/28/2010 11:15:00 AM
2 B 7/29/2010 8:50:00 AM
3 C 7/29/2010 8:55:00 AM
I have an object Show that has data from all the fields. Now I want to have a UI,
that displays count of shows on an hourly basis for all days..
Date 7/28/2010
Hours Count
11-12 1
Date 7/29/2010
Hours Count
8-9 2
I have no idea how I shall do it in C#(the logic for it.)Also, is there something like a explode funtion that we have in php, in C#. Because my database field has value
7/29/2010 8:55:00 AM and I want to break date and time. Can anybody help with logic to build the above UI?
As I want to display all hours and their counts for each date, will I have to use a listbox for dates and in that another listbox, with all hours and counts in that date?Can you show me how to do it?
Assuming you’re able to use LINQ, then you can do all the grouping and ordering in the C# fairly easily. (I’m assuming just a list of DateTime objects rather than full Show objects — it would appear you can get the DateTime for each Show with a simple LINQ Select statement.)
This provides the output:
Note that this is just a simple Console Application example. You have not specified what GUI technology you are using (WinForms, WPF), so I’ll leave it as an exercise to take the grouping results and apply them in a GUI.
Edit: Here is an example format in XAML using nested ItemsControls with DataBinding to a LINQ statement.
This uses a modified version of my original LINQ statement to make it easier for the DataBinding to be wired up. This code is in the constructor of my test Window.