本文整理汇总了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!
}
}