當前位置: 首頁>>代碼示例>>C#>>正文


C# CollectionType.Wrap方法代碼示例

本文整理匯總了C#中NHibernate.Type.CollectionType.Wrap方法的典型用法代碼示例。如果您正苦於以下問題:C# CollectionType.Wrap方法的具體用法?C# CollectionType.Wrap怎麽用?C# CollectionType.Wrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NHibernate.Type.CollectionType的用法示例。


在下文中一共展示了CollectionType.Wrap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProcessArrayOrNewCollection

		private object ProcessArrayOrNewCollection(object collection, CollectionType collectionType)
		{
			if (collection == null)
			{
				return null;
			}

			ICollectionPersister persister = Session.GetCollectionPersister(collectionType.Role);

			if (collectionType.IsArrayType)
			{
				PersistentArrayHolder ah = Session.GetArrayHolder(collection);
				if (ah == null)
				{
					ah = new PersistentArrayHolder(Session, collection);
					Session.AddNewCollection(ah, persister);
					Session.AddArrayHolder(ah);
				}
				return null;
			}
			else
			{
				IPersistentCollection persistentCollection = collectionType.Wrap(Session, collection);
				Session.AddNewCollection(persistentCollection, persister);

				if (log.IsDebugEnabled)
				{
					log.Debug("Wrapped collection in role: " + collectionType.Role);
				}

				return persistentCollection; //Force a substitution!
			}
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:33,代碼來源:WrapVisitor.cs

示例2: ProcessArrayOrNewCollection

		private object ProcessArrayOrNewCollection(object collection, CollectionType collectionType)
		{
			if (collection == null)
			{
				//do nothing
				return null;
			}

			ISessionImplementor session = Session;

			ICollectionPersister persister = session.Factory.GetCollectionPersister(collectionType.Role);
			
			IPersistenceContext persistenceContext = session.PersistenceContext;
			//TODO: move into collection type, so we can use polymorphism!

			if (collectionType.HasHolder(session.EntityMode))
			{
				if (collection == CollectionType.UnfetchedCollection)
					return null;

				IPersistentCollection ah = persistenceContext.GetCollectionHolder(collection);
				if (ah == null)
				{
					ah = collectionType.Wrap(session, collection);
					persistenceContext.AddNewCollection(persister, ah);
					persistenceContext.AddCollectionHolder(ah);
				}
				return null;
			}
			else
			{
				IPersistentCollection persistentCollection = collectionType.Wrap(session, collection);
				persistenceContext.AddNewCollection(persister, persistentCollection);

				if (log.IsDebugEnabled)
					log.Debug("Wrapped collection in role: " + collectionType.Role);

				return persistentCollection; //Force a substitution!
			}
		}
開發者ID:jlevitt,項目名稱:nhibernate-core,代碼行數:40,代碼來源:WrapVisitor.cs


注:本文中的NHibernate.Type.CollectionType.Wrap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。