【发布时间】:2013-05-03 07:37:55
【问题描述】:
据我了解,要添加子行,您可以这样做
parent.Children.Add(child);
或
child.Parents= 父母
然后你可以做 myContext.SaveChanges();
不知何故,第二种解决方案根本不做插入工作。这是我的代码:
CountMaster countMaster = (from b in pMDataContext.CountMasters
where b.ReportDate == reportDate && b.Department == dept
select b).SingleOrDefault();
CountDetail countDetail = new CountDetail { CategoryId = 1, StatusId = 1 };
//countMaster.CountDetails.Add(countDetail);
countDetail.CountMaster = countMaster;
pMDataContext.SaveChanges();
【问题讨论】:
标签: entity-framework frameworks entity-framework-4.1 entity