简体   繁体   English

我如何发现该对象已附加到特定的对象上下文?

[英]How can i discover that object is attached to specific Object Context?

if i have 2 objectContexts for the same model each one hold some objects.. 如果我有2个相同模型的objectContexts,则每个对象都保存一些对象。

How can i find that object is attached to specific Object Context? 我如何找到该对象附加到特定的对象上下文?

I have one solution by check the object With ObjectStateManager like this : 我有一种解决方案,方法是使用ObjectStateManager检查对象,如下所示:

bool isPresent = objectStateManager.TryGetObjectStateEntry(((IEntityWithKey)order).EntityKey, out stateEntry);
if (isPresent)
{
    Console.WriteLine("The entity was found");
}

is this will work always fine? 这会一直正常吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EF4无法将对象添加到上下文中,即使我确信它没有附加 - EF4 can’t add an object to the context even though I’m convinced it is not attached EF Core 2 对象未附加到上下文 - EF Core 2 Object Not Attached to Context 如何通过附加的属性获取TextProperty的绑定对象 - How can I get the binding object of TextProperty through an attached Property 无法附加对象,因为它已经在对象上下文中 - The object cannot be attached because it is already in the object context 如何判断Linq对象是否已附加到数据上下文? - How to tell if a Linq object has been attached to a data context? 如何发现设备是否连接到特定的串行(COM)端口? - How can I discover if a device is connected to a specific serial (COM) port? 如何在页面上下文之外获取全局资源对象? - How can I get the Global Resource Object outside of the context of a page? 如何从Spring上下文中获取所有对象标识符? - How can I get all the object identifiers from Spring context? 具有临时EntityKey值的对象无法附加到对象上下文 - An object with a temporary EntityKey value cannot be attached to an object context 如何访问计时器附带的对象? - How do I get access to the object which the Timer is attached to?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM