本文整理汇总了C#中IPersistenceContext.NarrowProxy方法的典型用法代码示例。如果您正苦于以下问题:C# IPersistenceContext.NarrowProxy方法的具体用法?C# IPersistenceContext.NarrowProxy怎么用?C# IPersistenceContext.NarrowProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPersistenceContext
的用法示例。
在下文中一共展示了IPersistenceContext.NarrowProxy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnNarrowedProxy
/// <summary>
/// Given that there is a pre-existing proxy.
/// Initialize it if necessary; narrow if necessary.
/// </summary>
private object ReturnNarrowedProxy(LoadEvent @event, IEntityPersister persister, EntityKey keyToLoad, LoadType options, IPersistenceContext persistenceContext, object proxy)
{
log.Debug("entity proxy found in session cache");
var castedProxy = (INHibernateProxy) proxy;
ILazyInitializer li = castedProxy.HibernateLazyInitializer;
if (li.Unwrap)
{
return li.GetImplementation();
}
object impl = null;
if (!options.IsAllowProxyCreation)
{
impl = Load(@event, persister, keyToLoad, options);
// NH Different behavior : NH-1252
if (impl == null && !options.IsAllowNulls)
{
@event.Session.Factory.EntityNotFoundDelegate.HandleEntityNotFound(persister.EntityName, keyToLoad.Identifier);
}
}
if (impl == null && !options.IsAllowProxyCreation && options.ExactPersister)
{
// NH Different behavior : NH-1252
return null;
}
return persistenceContext.NarrowProxy(castedProxy, persister, keyToLoad, impl);
}