[英]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.