Linq:当我尝试使用FK关系更改字段值时发生错误更新 [英] Linq:error update when I try to change field value with a FK relation
本文介绍了Linq:当我尝试使用FK关系更改字段值时发生错误更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,您怎么看待这个错误?
我正在使用Linq技术(DataContext类e linqDBClass.dbml)
当我尝试更新记录时遇到此错误:
由于对象的当前状态,操作无效"
更新工作正常,除非在这种情况下:
当我尝试更改字段值E1_Code(FK关系)时.
Hello,what do you think about this error?
I''m using Linq technologies (DataContext class e linqDBClass.dbml)
When I try to update a record I faced this error:
"Operation is not valid due to the current state of the object"
Update works fine except in this case:
When I try to change field value E1_Code(FK relation).
Entity1
E1_ID
E1_Attibute
E1_Code (FK -->E1_Code on E2_Code)
Entity2
E2_Code
E2_Description
我怎么解决这个问题?
请帮帮我.
How can I solve this problem?
Please help me.
Thanks
推荐答案
您必须先分离对象,然后才能更改导航属性.尽管这并不简单.从此处开始: LINQ to SQL-分离实体 [
You have to detach the object before changing navigation property. Although this is not straightforward. Start here: LINQ to SQL - Detach Entities[^]
这篇关于Linq:当我尝试使用FK关系更改字段值时发生错误更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文