在客户端,我将所有相关实体(导航属性)添加到我的主实体并将其附加到列表并调用SubmitChange。但是在服务器端,所有相关的实体都不见了!
代码:
客户:
DomainService1 domainService1= new DomainService1();
.
.
.
WorkCode newWorkCode = new WorkCode();
newWorkCode.Date = DateTime.Now;
.
.
.
for(Work item in WorkList)
{
newWorkCode.Works.Add(item)
}
.
.
.
domainService1.WorkCodes.Attach(newWorkCode);
domainService1.InsertWorkCode(newWorkCode);
dsMaintenance.SubmitChanges(submitOperation =>
{
if (!submitOperation.HasError)
{
}
},
null);
服务器:
[Update(UsingCustomMethod = true)]
public void InsertWorkCode(WorkCode workCode)
{
//////// workCode.Works = 0 ///////////////////
this.ObjectContext.WorkCodes.AddObject(workCode);
}