私のDBテーブルは次のようになります。
Room Item Description
------------------------------------
Bedroom Chair Leather
Bedroom Bed Comfortable
Office Desk Very Small
Office Book Shelf Lot of Books
このDBテーブルを次のディクショナリタイプのオブジェクトに入力します
Dictionary<string, Dictionary<string,string>
どうすればよいですか?
私は次のようにコードを書き始めましたが、正しく入力する方法がわからないため、これ以上進むことができませんでした。
Dictionary<string, Dictionary<string,string>> roomfurnitures= new Dictionary<string,Dictionary<string, string>>();
Dictionary<string, string> furniture= new Dictionary<string, string>();
using (SqlDataReader reader = this.m_cmdGetFurnitureByRoom.ExecuteReader())
{
while (reader.Read())
{
string roomtype = reader.GetString(reader.GetOrdinal("Room"));
string item = reader.GetString(reader.GetOrdinal("Item"));
string description = reader.GetString(reader.GetOrdinal("Description"));
//I do not know how to populate the roomfurnitures dictionary poperly
}
}
roomfurnitures辞書が適切に入力されたら、次のように表示します。助けてください。
Bedroom Chair Leather
Bed Comfortable
Office Desk VerySmall
BookShelf Lot of Books