WCF数据服务异常

时间:2010-05-20 04:28:29

标签: wcf wcf-data-services

我正在使用 ADO.NET Dataservice WCF数据服务在C#.Net上工作。

我尝试将一条记录更新为关系表,当我到达context.SetLink()时,我得到exception("The context is not currently tracking the entity")。我不知道如何解决这个问题。我的代码在下面指定。

LogNote dbLogNote =logNote;
LogSubSession dbLogSubSession = (from p in context.LogSubSession
                                 where p.UID == logNote.SubSessionId
                                 select p).First<LogSubSession>()
                                 as LogSubSession;
context.AddToLogNote(dbLogNote);
dbLogNote.LogSubSession = dbLogSubSession;
context.SetLink(dbLogNote, "LogSubSession", dbLogSubSession);
context.SaveChanges();

此处LogSubSession是主表,LogNote是外表。我正在基于主键表将数据更新到外表中。

由于

1 个答案:

答案 0 :(得分:0)

尝试使用AttachLink()让实体知道开始跟踪链接。