本文整理汇总了C#中IPersistentCollection.InitializeFromCache方法的典型用法代码示例。如果您正苦于以下问题:C# IPersistentCollection.InitializeFromCache方法的具体用法?C# IPersistentCollection.InitializeFromCache怎么用?C# IPersistentCollection.InitializeFromCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPersistentCollection
的用法示例。
在下文中一共展示了IPersistentCollection.InitializeFromCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Assemble
public virtual void Assemble(IPersistentCollection collection, ICollectionPersister persister, object owner)
{
collection.InitializeFromCache(persister, state, owner);
collection.AfterInitialize(persister);
}
示例2: InitializeCollectionFromCache
/// <summary> Try to initialize a collection from the cache</summary>
private bool InitializeCollectionFromCache(object id, ICollectionPersister persister, IPersistentCollection collection, ISessionImplementor source)
{
if (!(source.EnabledFilters.Count == 0) && persister.IsAffectedByEnabledFilters(source))
{
log.Debug("disregarding cached version (if any) of collection due to enabled filters ");
return false;
}
bool useCache = persister.HasCache && ((source.CacheMode & CacheMode.Get) == CacheMode.Get);
if (!useCache)
{
return false;
}
else
{
ISessionFactoryImplementor factory = source.Factory;
CacheKey ck = new CacheKey(id, persister.KeyType, persister.Role, source.EntityMode, factory);
object ce = persister.Cache.Get(ck, source.Timestamp);
if (factory.Statistics.IsStatisticsEnabled)
{
if (ce == null)
{
factory.StatisticsImplementor.SecondLevelCacheMiss(persister.Cache.RegionName);
}
else
{
factory.StatisticsImplementor.SecondLevelCacheHit(persister.Cache.RegionName);
}
}
if (ce == null)
{
return false;
}
else
{
IPersistenceContext persistenceContext = source.PersistenceContext;
// NH Different implementation but similar behavior H3.2 CollectionCacheEntry.Assemble do de same
collection.InitializeFromCache(persister, ce, persistenceContext.GetCollectionOwner(id, persister));
collection.AfterInitialize(persister);
persistenceContext.GetCollectionEntry(collection).PostInitialize(collection);
return true;
}
}
}