I have the following dictionary:
Dictionary messages = new Dictionary<int, dictionary<string, List<string>>>();
I need somehow to get the contents of this dictionary into a datagridview. The DGV should have 3 columns: ID, Message and Tags. The ID is the ID number of the message (the integer). The Message is, well, the message (the string). The list of tags is whatever tags are linked to this message, there could be everything from 1 to 6 different tags.
The dictionary is composed from the results of an SQL query. I thought of doing it this way, in order to remove duplicates of the messages. The SQL tables are made according to the accepted answer in this question: Building a relation between tables
Or am I perhaps thinking completely wrong? Could I use an SQL query to achieve what I want?
What I wish to achieve is: Getting the results from the query presented as:
| ID | Message1 | Tag1, tag2, tag3, tag4 |
| ID | Message2 | Tag1, tag2, tag3, tag4 |
| ID | Message3 | Tag1, tag2, tag3, tag4 |
Instead of as it is presented now:
| ID | Message1 | Tag1 |
| ID | Message1 | Tag2 |
| ID | Message1 | Tag3 |
| ID | Message2 | Tag1 |
| ID | Message2 | Tag2 |
| ID | Message2 | Tag3 |
The query I am using at the moment is:
SELECT t.message_ID, m.message, t.tagName FROM tbl_messages m JOIN tbl_messages_x_tbl_tags t ON m.message_ID = t.message_ID WHERE t.tagName='tag1' OR t.tagName='tag2'