• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IPersistentCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IPersistentCollection的典型用法代码示例。如果您正苦于以下问题:C# IPersistentCollection类的具体用法?C# IPersistentCollection怎么用?C# IPersistentCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IPersistentCollection类属于命名空间,在下文中一共展示了IPersistentCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadingCollectionEntry

		public LoadingCollectionEntry(IDataReader resultSet, ICollectionPersister persister, object key, IPersistentCollection collection)
		{
			this.resultSet = resultSet;
			this.persister = persister;
			this.key = key;
			this.collection = collection;
		}
开发者ID:ray2006,项目名称:WCell,代码行数:7,代码来源:LoadingCollectionEntry.cs


示例2: ProcessReachableCollection

        /// <summary> 
        /// Initialize the role of the collection. 
        /// </summary>
        /// <param name="collection">The collection to be updated by reachibility. </param>
        /// <param name="type">The type of the collection. </param>
        /// <param name="entity">The owner of the collection. </param>
        /// <param name="session">The session.</param>
        public static void ProcessReachableCollection(IPersistentCollection collection, CollectionType type, object entity, ISessionImplementor session)
        {
            collection.Owner = entity;
            CollectionEntry ce = session.PersistenceContext.GetCollectionEntry(collection);

            if (ce == null)
            {
                // refer to comment in StatefulPersistenceContext.addCollection()
                throw new HibernateException(string.Format("Found two representations of same collection: {0}", type.Role));
            }

            // The CollectionEntry.isReached() stuff is just to detect any silly users
            // who set up circular or shared references between/to collections.
            if (ce.IsReached)
            {
                // We've been here before
                throw new HibernateException(string.Format("Found shared references to a collection: {0}", type.Role));
            }
            ce.IsReached = true;

            ISessionFactoryImplementor factory = session.Factory;
            ICollectionPersister persister = factory.GetCollectionPersister(type.Role);
            ce.CurrentPersister = persister;
            ce.CurrentKey = type.GetKeyOfOwner(entity, session); //TODO: better to pass the id in as an argument?

            if (log.IsDebugEnabled)
            {
                log.Debug("Collection found: " +
                    MessageHelper.InfoString(persister, ce.CurrentKey, factory) + ", was: " +
                    MessageHelper.InfoString(ce.LoadedPersister, ce.LoadedKey, factory) +
                    (collection.WasInitialized ? " (initialized)" : " (uninitialized)"));
            }

            PrepareCollectionForUpdate(collection, ce);
        }
开发者ID:zibler,项目名称:zibler,代码行数:42,代码来源:Collections.cs


示例3: Conj

        public static IPersistentCollection Conj(IPersistentCollection collection, object obj)
        {
            if (collection == null)
                return new PersistentList(obj);

            return collection.Cons(obj);
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:7,代码来源:Operations.cs


示例4: CollectionUpdateAction

 public CollectionUpdateAction(
     IPersistentCollection collection, ICollectionPersister persister,
     object key, bool emptySnapshot, ISessionImplementor session)
     : base(persister, collection, key, session)
 {
     this.emptySnapshot = emptySnapshot;
 }
开发者ID:zibler,项目名称:zibler,代码行数:7,代码来源:CollectionUpdateAction.cs


示例5: ScheduledCollectionUpdate

		/// <summary>
		/// Initializes a new instance of <see cref="ScheduledCollectionUpdate"/>.
		/// </summary>
		/// <param name="collection">The <see cref="IPersistentCollection"/> to update.</param>
		/// <param name="persister">The <see cref="ICollectionPersister"/> that is responsible for the persisting the Collection.</param>
		/// <param name="id">The identifier of the Collection owner.</param>
		/// <param name="emptySnapshot">Indicates if the Collection was empty when it was loaded.</param>
		/// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param>
		public ScheduledCollectionUpdate(IPersistentCollection collection, ICollectionPersister persister, object id,
		                                 bool emptySnapshot, ISessionImplementor session)
			: base(persister, id, session)
		{
			_collection = collection;
			_emptySnapshot = emptySnapshot;
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:15,代码来源:ScheduledCollectionUpdate.cs


示例6: MapCollectionChanges

 public IList<PersistentCollectionChangeData> MapCollectionChanges(String referencingPropertyName,
     IPersistentCollection newColl,
     object oldColl,
     object id)
 {
     return null;
 }
开发者ID:hazzik,项目名称:nhcontrib-all,代码行数:7,代码来源:OneToOneNotOwningMapper.cs


示例7: MapCollectionChanges

        public IList<PersistentCollectionChangeData> MapCollectionChanges(string referencingPropertyName,
																		IPersistentCollection newColl,
																		object oldColl,
																		object id)
        {
            return _delegate.MapCollectionChanges(referencingPropertyName, newColl, oldColl, id);
        }
开发者ID:umittal,项目名称:MunimJi,代码行数:7,代码来源:ComponentPropertyMapper.cs


示例8: 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


示例9: AbstractCollectionEvent

		/// <summary> Constructs an AbstractCollectionEvent object. </summary>
		/// <param name="collectionPersister">The collection persister.</param>
		/// <param name="collection">The collection </param>
		/// <param name="source">The Session source </param>
		/// <param name="affectedOwner">The owner that is affected by this event; can be null if unavailable </param>
		/// <param name="affectedOwnerId">
		/// The ID for the owner that is affected by this event; can be null if unavailable
		/// that is affected by this event; can be null if unavailable
		/// </param>
		protected AbstractCollectionEvent(ICollectionPersister collectionPersister, IPersistentCollection collection,
		                               IEventSource source, object affectedOwner, object affectedOwnerId) : base(source)
		{
			this.collection = collection;
			this.affectedOwner = affectedOwner;
			this.affectedOwnerId = affectedOwnerId;
			affectedOwnerEntityName = GetAffectedOwnerEntityName(collectionPersister, affectedOwner, source);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:17,代码来源:AbstractCollectionEvent.cs


示例10: ProcessNeverReferencedCollection

		private static void ProcessNeverReferencedCollection(IPersistentCollection coll, ISessionImplementor session)
		{
			CollectionEntry entry = session.PersistenceContext.GetCollectionEntry(coll);

			log.Debug("Found collection with unloaded owner: " + MessageHelper.InfoString(entry.LoadedPersister, entry.LoadedKey, session.Factory));

			entry.CurrentPersister = entry.LoadedPersister;
			entry.CurrentKey = entry.LoadedKey;

			PrepareCollectionForUpdate(coll, entry);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:11,代码来源:Collections.cs


示例11: ProcessUnreachableCollection

		/// <summary> 
		/// Record the fact that this collection was dereferenced 
		/// </summary>
		/// <param name="coll">The collection to be updated by unreachability. </param>
		/// <param name="session">The session.</param>
		public static void ProcessUnreachableCollection(IPersistentCollection coll, ISessionImplementor session)
		{
			if (coll.Owner == null)
			{
				ProcessNeverReferencedCollection(coll, session);
			}
			else
			{
				ProcessDereferencedCollection(coll, session);
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:16,代码来源:Collections.cs


示例12: PersistentCollectionChangeWorkUnit

        public PersistentCollectionChangeWorkUnit(ISessionImplementor sessionImplementor, String entityName,
            AuditConfiguration auditCfg, IPersistentCollection collection,
            CollectionEntry collectionEntry, Object snapshot, Object id,
            String referencingPropertyName)
            : base(sessionImplementor, entityName, auditCfg, 
                    new PersistentCollectionChangeWorkUnitId(id, collectionEntry.Role))
        {
            this.ReferencingPropertyName = referencingPropertyName;

            collectionChanges = auditCfg.EntCfg[EntityName].PropertyMapper
                    .MapCollectionChanges(referencingPropertyName, collection, snapshot, id);
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:12,代码来源:PersistentCollectionChangeWorkUnit.cs


示例13: EvictCollection

		private void EvictCollection(IPersistentCollection collection)
		{
			CollectionEntry ce = (CollectionEntry)Session.PersistenceContext.CollectionEntries[collection];
			Session.PersistenceContext.CollectionEntries.Remove(collection);
			if (log.IsDebugEnabled)
				log.Debug("evicting collection: " + MessageHelper.InfoString(ce.LoadedPersister, ce.LoadedKey, Session.Factory));
			if (ce.LoadedPersister != null && ce.LoadedKey != null)
			{
				//TODO: is this 100% correct?
				Session.PersistenceContext.CollectionsByKey.Remove(new CollectionKey(ce.LoadedPersister, ce.LoadedKey, Session.EntityMode));
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:12,代码来源:EvictVisitor.cs


示例14: CollectionRemoveAction

		/// <summary> 
		/// Removes a persistent collection from its loaded owner. 
		/// </summary>
		/// <param name="collection">The collection to to remove; must be non-null </param>
		/// <param name="persister"> The collection's persister </param>
		/// <param name="id">The collection key </param>
		/// <param name="emptySnapshot">Indicates if the snapshot is empty </param>
		/// <param name="session">The session </param>
		/// <remarks>Use this constructor when the collection is non-null.</remarks>
		public CollectionRemoveAction(IPersistentCollection collection, ICollectionPersister persister, object id,
		                              bool emptySnapshot, ISessionImplementor session)
			: base(persister, collection, id, session)
		{
			if (collection == null)
			{
				throw new AssertionFailure("collection == null");
			}

			this.emptySnapshot = emptySnapshot;
			affectedOwner = session.PersistenceContext.GetLoadedCollectionOwnerOrNull(collection);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:21,代码来源:CollectionRemoveAction.cs


示例15: ProcessDereferencedCollection

		private static void ProcessDereferencedCollection(IPersistentCollection coll, ISessionImplementor session)
		{
			IPersistenceContext persistenceContext = session.PersistenceContext;
			CollectionEntry entry = persistenceContext.GetCollectionEntry(coll);
			ICollectionPersister loadedPersister = entry.LoadedPersister;

			if (log.IsDebugEnabled && loadedPersister != null)
				log.Debug("Collection dereferenced: " + MessageHelper.InfoString(loadedPersister, entry.LoadedKey, session.Factory));

			// do a check
			bool hasOrphanDelete = loadedPersister != null && loadedPersister.HasOrphanDelete;
			if (hasOrphanDelete)
			{
				object ownerId = loadedPersister.OwnerEntityPersister.GetIdentifier(coll.Owner, session.EntityMode);
				// TODO NH Different behavior
				//if (ownerId == null)
				//{
				//  // the owning entity may have been deleted and its identifier unset due to
				//  // identifier-rollback; in which case, try to look up its identifier from
				//  // the persistence context
				//  if (session.Factory.Settings.IsIdentifierRollbackEnabled)
				//  {
				//    EntityEntry ownerEntry = persistenceContext.GetEntry(coll.Owner);
				//    if (ownerEntry != null)
				//    {
				//      ownerId = ownerEntry.Id;
				//    }
				//  }
				//  if (ownerId == null)
				//  {
				//    throw new AssertionFailure("Unable to determine collection owner identifier for orphan-delete processing");
				//  }
				//}
				EntityKey key = new EntityKey(ownerId, loadedPersister.OwnerEntityPersister, session.EntityMode);
				object owner = persistenceContext.GetEntity(key);
				if (owner == null)
				{
					throw new AssertionFailure("collection owner not associated with session: " + loadedPersister.Role);
				}
				EntityEntry e = persistenceContext.GetEntry(owner);
				//only collections belonging to deleted entities are allowed to be dereferenced in the case of orphan delete
				if (e != null && e.Status != Status.Deleted && e.Status != Status.Gone)
				{
					throw new HibernateException("A collection with cascade=\"all-delete-orphan\" was no longer referenced by the owning entity instance: " + loadedPersister.Role);
				}
			}

			// do the work
			entry.CurrentPersister = null;
			entry.CurrentKey = null;
			PrepareCollectionForUpdate(coll, entry, session.EntityMode, session.Factory);
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:52,代码来源:Collections.cs


示例16: MonthlyLogFilesHeuristics

        public MonthlyLogFilesHeuristics([NotNull] IPersistentCollection heuristicsPersistentCollection,
            IWurmLogFiles wurmLogFiles,
            MonthlyHeuristicsExtractorFactory monthlyHeuristicsExtractorFactory)
        {
            if (heuristicsPersistentCollection == null)
                throw new ArgumentNullException("heuristicsPersistentCollection");
            if (wurmLogFiles == null) throw new ArgumentNullException("wurmLogFiles");
            if (monthlyHeuristicsExtractorFactory == null) throw new ArgumentNullException("monthlyHeuristicsExtractorFactory");

            this.heuristicsPersistentCollection = heuristicsPersistentCollection;
            this.wurmLogFiles = wurmLogFiles;
            this.monthlyHeuristicsExtractorFactory = monthlyHeuristicsExtractorFactory;
        }
开发者ID:imtheman,项目名称:WurmApi,代码行数:13,代码来源:MonthlyLogFilesHeuristics.cs


示例17: ReattachCollection

        /// <summary> 
        /// Reattach a detached (disassociated) initialized or uninitialized
        /// collection wrapper, using a snapshot carried with the collection wrapper
        /// </summary>
        protected internal void ReattachCollection(IPersistentCollection collection, ICollectionSnapshot snapshot)
        {
            if (collection.WasInitialized)
            {
                Session.PersistenceContext.AddInitializedDetachedCollection(collection, snapshot);
            }
            else
            {
                if (!IsCollectionSnapshotValid(snapshot))
                    throw new HibernateException("could not reassociate uninitialized transient collection");

                Session.PersistenceContext.AddUninitializedDetachedCollection(collection, snapshot);
            }
        }
开发者ID:zibler,项目名称:zibler,代码行数:18,代码来源:ProxyVisitor.cs


示例18: PrepareCollectionForUpdate

        //1. record the collection role that this collection is referenced by
        //2. decide if the collection needs deleting/creating/updating (but don't actually schedule the action yet)
        private static void PrepareCollectionForUpdate(IPersistentCollection coll, CollectionEntry entry)
        {
            if (entry.IsProcessed)
                throw new AssertionFailure("collection was processed twice by flush()");

            entry.IsProcessed = true;

            ICollectionPersister loadedPersister = entry.LoadedPersister;
            ICollectionPersister currentPersister = entry.CurrentPersister;
            if (loadedPersister != null || currentPersister != null)
            {
                // it is or was referenced _somewhere_
                bool ownerChanged = loadedPersister != currentPersister ||
                    !currentPersister.KeyType.IsEqual(entry.LoadedKey, entry.CurrentKey, EntityMode.Poco);

                if (ownerChanged)
                {
                    // do a check
                    bool orphanDeleteAndRoleChanged = loadedPersister != null &&
                        currentPersister != null && loadedPersister.HasOrphanDelete;

                    if (orphanDeleteAndRoleChanged)
                    {
                        throw new HibernateException("Don't change the reference to a collection with cascade=\"all-delete-orphan\": " + loadedPersister.Role);
                    }

                    // do the work
                    if (currentPersister != null)
                    {
                        entry.IsDorecreate = true; // we will need to create new entries
                    }

                    if (loadedPersister != null)
                    {
                        entry.IsDoremove = true; // we will need to remove ye olde entries
                        if (entry.IsDorecreate)
                        {
                            log.Debug("Forcing collection initialization");
                            coll.ForceInitialization(); // force initialize!
                        }
                    }
                }
                else if (coll.IsDirty)
                {
                    // else if it's elements changed
                    entry.IsDoupdate = true;
                }
            }
        }
开发者ID:zibler,项目名称:zibler,代码行数:51,代码来源:Collections.cs


示例19: ReattachCollection

		/// <summary> 
		/// Reattach a detached (disassociated) initialized or uninitialized
		/// collection wrapper, using a snapshot carried with the collection wrapper
		/// </summary>
		protected internal void ReattachCollection(IPersistentCollection collection, CollectionType type)
		{
			if (collection.WasInitialized)
			{
				ICollectionPersister collectionPersister = Session.Factory.GetCollectionPersister(type.Role);
				Session.PersistenceContext.AddInitializedDetachedCollection(collectionPersister, collection);
			}
			else
			{
				if (!IsCollectionSnapshotValid(collection))
				{
					throw new HibernateException("could not reassociate uninitialized transient collection");
				}
				ICollectionPersister collectionPersister = Session.Factory.GetCollectionPersister(collection.Role);
				Session.PersistenceContext.AddUninitializedDetachedCollection(collectionPersister, collection);
			}
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:21,代码来源:ProxyVisitor.cs


示例20: MapCollectionChanges

        public IList<PersistentCollectionChangeData> MapCollectionChanges(String referencingPropertyName,
            IPersistentCollection newColl,
            Object oldColl,
            Object id)
        {
            IList<PersistentCollectionChangeData> parentCollectionChanges = parentMapper.MapCollectionChanges(
                    referencingPropertyName, newColl, oldColl, id);

            IList<PersistentCollectionChangeData> mainCollectionChanges = main.MapCollectionChanges(
                    referencingPropertyName, newColl, oldColl, id);

            if (parentCollectionChanges == null) {
                return mainCollectionChanges;
            } else {
                if(mainCollectionChanges != null) {
                    parentCollectionChanges.Concat(mainCollectionChanges);
                }
                return parentCollectionChanges;
            }
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:20,代码来源:SubclassPropertyMapper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IPersistentMap类代码示例发布时间:2022-05-24
下一篇:
C# IPersistent类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap