本文整理汇总了C#中ICollectionPersister.IsAffectedByEnabledFilters方法的典型用法代码示例。如果您正苦于以下问题:C# ICollectionPersister.IsAffectedByEnabledFilters方法的具体用法?C# ICollectionPersister.IsAffectedByEnabledFilters怎么用?C# ICollectionPersister.IsAffectedByEnabledFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollectionPersister
的用法示例。
在下文中一共展示了ICollectionPersister.IsAffectedByEnabledFilters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
{
log.DebugFormat("Collection cache miss: {0}", ck);
}
else
{
log.DebugFormat("Collection cache hit: {0}", ck);
}
if (ce == null)
{
return false;
}
else
{
IPersistenceContext persistenceContext = source.PersistenceContext;
CollectionCacheEntry cacheEntry = (CollectionCacheEntry)persister.CacheEntryStructure.Destructure(ce, factory);
cacheEntry.Assemble(collection, persister, persistenceContext.GetCollectionOwner(id, persister));
persistenceContext.GetCollectionEntry(collection).PostInitialize(collection);
return true;
}
}
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:60,代码来源:DefaultInitializeCollectionEventListener.cs
示例2: AddCollectionToCache
/// <summary> Add the collection to the second-level cache </summary>
/// <param name="lce">The entry representing the collection to add </param>
/// <param name="persister">The persister </param>
private void AddCollectionToCache(LoadingCollectionEntry lce, ICollectionPersister persister)
{
ISessionImplementor session = LoadContext.PersistenceContext.Session;
ISessionFactoryImplementor factory = session.Factory;
if (log.IsDebugEnabled)
{
log.Debug("Caching collection: " + MessageHelper.InfoString(persister, lce.Key, factory));
}
if (!(session.EnabledFilters.Count == 0) && persister.IsAffectedByEnabledFilters(session))
{
// some filters affecting the collection are enabled on the session, so do not do the put into the cache.
log.Debug("Refusing to add to cache due to enabled filters");
// todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered;
// but CacheKey is currently used for both collections and entities; would ideally need to define two separate ones;
// currently this works in conjunction with the check on
// DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read from
// cache with enabled filters).
return; // EARLY EXIT!!!!!
}
IComparer versionComparator;
object version;
if (persister.IsVersioned)
{
versionComparator = persister.OwnerEntityPersister.VersionType.Comparator;
object collectionOwner = LoadContext.PersistenceContext.GetCollectionOwner(lce.Key, persister);
version = LoadContext.PersistenceContext.GetEntry(collectionOwner).Version;
}
else
{
version = null;
versionComparator = null;
}
CollectionCacheEntry entry = new CollectionCacheEntry(lce.Collection, persister);
CacheKey cacheKey = session.GenerateCacheKey(lce.Key, persister.KeyType, persister.Role);
bool put = persister.Cache.Put(cacheKey, persister.CacheEntryStructure.Structure(entry),
session.Timestamp, version, versionComparator,
factory.Settings.IsMinimalPutsEnabled && session.CacheMode != CacheMode.Refresh);
if (put && factory.Statistics.IsStatisticsEnabled)
{
factory.StatisticsImplementor.SecondLevelCachePut(persister.Cache.RegionName);
}
}