I have a question on mind for a few long days. Finally, I made a SQL query, which I want to show in MVC4 View. I build following SQL query:
select distinct date, max(priority) from Timetables where date between '2013-12-01' and '2013-12-31' group by date
which returns me a collection of dates and max priorities of that dates. That is OK for me. I am totaly okay, when this query returns me a whole Timetables record. But I need to pass result of this query to View engine of MVC4. I had some tries, but I am nowhere near finding a result for that. If you have some other possibilities, how to do that, I am eager to hear :)
Also, I am using an Entity Framework.
Thanks!
e: The database looks like that:
id | doctor_id | nurse_id | date | start_time | end_time |time_for_pacient| priority |comments
-----------------------------------------------------------------------------------------
1 | 5 | 4 | 13-12-01| 07:00 | 11:30 | 00:20 | 1 |Normal
2 | 5 | 4 | 13-12-02| 07:00 | 11:30 | 00:20 | 1 |Normal
3 | 5 | 4 | 13-12-01| 08:00 | 10:30 | 00:20 | 2 |Shorten
4 | 5 | 4 | 13-12-02| 06:00 | 10:30 | 00:10 | 3 |Extra
the result I want to achieve in View:
id | doctor_id | nurse_id | date | start_time | end_time |time_for_pacient| priority |comments
-----------------------------------------------------------------------------------------------------
3 | 5 | 4 | 13-12-01| 08:00 | 10:30 | 00:20 | 2 |Shorten
4 | 5 | 4 | 13-12-02| 06:00 | 10:30 | 00:10 | 3 |Extra
I just want to show a single record for each day with highest priority.