问题描述
想有一个像样的机制,允许使用ObservableCollections的选项dynmically让他们用一个编辑窗口,并绑定更新几个选项,而无须作出有关绑定控件的变化更新了全球收藏,迄今最好的后解决方案似乎是:克隆实体,取下旧的,附加新的,标记它更新和保存
After trying several options of having a decent mechanism which allows to use ObservableCollections with the option to dynmically having them updated using an Edit window and binding, without having the global collections updated while making changes on the bound controls, so far the best solution seems to be : Clone the entity, detach the old one, attach the new one, mark it updated and save.
但请注意,以下例外如下:
But oops, the following exception follows:
The relationship manager supplied by the object implementing IEntityWithRelationships is not the expected relationship manager.
请问有人知道如何解决这个问题?
Does someone knows how to solve this ?
b.t.w - 请不要提供使用序列化,也不反射或马蒂厄MEZIL
实体拷贝机从性能问题(需要几秒钟复制整个entitygraph)。
b.t.w - Please dont offer to use serialization, nor reflection or the Matthieu MEZIL entity cloner as from performance issue (takes several seconds to copy the whole entitygraph).
谢谢,
奥兰
推荐答案
我会质疑你的方法。 需要几秒钟复制整个实体图应敲响了一些警钟。这听起来像你存储的大部分数据在内存中。因为你可以并不意味着你应该。我会尝试重新设计使用延迟加载。
I would question your approach. "takes several seconds to copy the whole entity graph" should be ringing some alarm bells. It sounds like you are storing the most of your data in memory. Just because you can doesn't mean you should. I would try re-architect you use deferred loading.
不过的是,您使用的分离实体(POCO的方法)虽这么说?这可能会在这方面提供帮助,因为他们对上下文脱钩,这可能会给你的灵活性带来的实体进出上下文的。
However that being said, are you using decoupled entities (The POCO approach)? This might help in this regard since they decouple from the context more and this might give you the flexibility to bring entities in and out of the context.
这篇关于实体框架连接异常克隆后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!