【发布时间】:2012-03-29 13:07:47
【问题描述】:
我需要在“StaffSectionInCharge”表中添加一些记录,它只有两列 StaffId 和 SectionId,我有 StaffId 和 StudentId 的值.....问题是我不能直接将记录添加到这个表.....我使用实体框架,这个表的设计是
[EdmRelationshipNavigationPropertyAttribute("Model", "StaffSectionInCharge", "Section")]
public EntityCollection<Section> Sections
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Section>("Model.StaffSectionInCharge", "Section");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Section>("Model.StaffSectionInCharge", "Section", value);
}
}
}
我需要通过 Staff 表访问这个表,我试过了
DataAccess.Staff staff = buDataEntities.Staffs.First(s=>s.StaffId==StaffId);
staff.Sections.Add();
卡在这里,不能再往前走,谁能帮帮我
【问题讨论】:
标签: entity-framework