【发布时间】:2015-09-22 12:36:33
【问题描述】:
我的数据在两个表中
Master Columns
ID MyDateTime
1 07 Sept
2 08 Sept
上面的 MyDatetime 列具有唯一索引
Detail Columns
ID Data1 Data2 Data3
1 a b c
1 x y z
1 f g h
2 a b c
我想将其填充到字典中。我试过了
Dictionary<DateTime, List<Detail>> result = (
from master in db.master
from details in db.detail
where (master.ID == detail.ID)
select new
{
master.MyDateTime,
details
}).Distinct().ToDictionary(key => key.MyDateTime, value => new List<Detail> { value.details });
我希望字典中有两行
1, List of 3 rows as details
2, List of 1 row as details
我收到一个错误,它抱怨输入了两次字典的键。关键是主数据中唯一的日期时间
【问题讨论】:
标签: c# linq dictionary