I am working on C#.Net with ADO.NET Dataservice WCF Data Services.
I try to update one record to relational table, when I reach context.SetLink()
I am getting exception("The context is not currently tracking the entity")
. I don't know how to solve this problem. My code is specified below.
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();
Here LogSubSession
is a primary table an开发者_如何学God LogNote
is a foreign table. I am updating data into foreign table based on primary key table.
Thanks
Try using AttachLink() to let the entity know to start tracking the link.
精彩评论