当前位置: 首页>>代码示例>>C#>>正文


C# IPersistentCollection.InitializeFromCache方法代码示例

本文整理汇总了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);
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:5,代码来源:CollectionCacheEntry.cs

示例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;
                }
            }
        }
开发者ID:zibler,项目名称:zibler,代码行数:51,代码来源:DefaultInitializeCollectionEventListener.cs


注:本文中的IPersistentCollection.InitializeFromCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。