在ADO .net实体框架中更新分离的实体 [英] Update a detached entity in ADO .net entity framework
问题描述
我刚刚开始研究ADO .Net实体框架,到目前为止我喜欢我看到的内容。
唯一的问题是我能看到的大多数使用场景都有一个非常短暂的实体上下文。因此,最好的想法似乎是我应该以分离模式检索所有数据,将其发送到表示层(通过web服务或直接),它作用于它并返回业务层以进行更新。
我非常讨厌我必须要么:
1)再次点击数据库以检索实体的旧状态,然后更新它
/ p>
在我的情况下,你的方法都不适合我。
当我尝试附加时我得到一个错误" [System.InvalidOperationException] = {"实体对象不能被多个IEntityChangeTracker实例引用。"}"
所以,我猜它已经附加了吗?
即使这样,e ntity未更新....
Hi,
I have just started working on the ADO .Net Entity Framework and so far I like what I see.
The only problem is that most of the usage scenarios that I can see have a very short lived Entity Context. So the best idea seems to be that I should retrieve all the data in detached mode, send it to the presentation layer (through a webservice or directly) which acts on it and returns it the business layer for update.
I seriously hate the fact that I have to either:
1) Hit the database again to retrieve the old state of the entity, and then update it
in my case, none of your approaches work for me.
when i try to attach i get an error "[System.InvalidOperationException] = {"An entity object cannot be referenced by multiple instances of IEntityChangeTracker."}"
so, i guess its already attached right?
even that way, entity is not updated....
这篇关于在ADO .net实体框架中更新分离的实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!