本文整理匯總了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!
}
}
示例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!
}
}