本文整理汇总了C#中ISessionImplementor.InitializeCollection方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionImplementor.InitializeCollection方法的具体用法?C# ISessionImplementor.InitializeCollection怎么用?C# ISessionImplementor.InitializeCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISessionImplementor
的用法示例。
在下文中一共展示了ISessionImplementor.InitializeCollection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCollection
public object GetCollection(object key, ISessionImplementor session, object owner)
{
ICollectionPersister persister = GetPersister(session);
IPersistenceContext persistenceContext = session.PersistenceContext;
EntityMode entityMode = session.EntityMode;
if (entityMode == EntityMode.Xml && !isEmbeddedInXML)
{
return UnfetchedCollection;
}
// check if collection is currently being loaded
IPersistentCollection collection = persistenceContext.LoadContexts.LocateLoadingCollection(persister, key);
if (collection == null)
{
// check if it is already completely loaded, but unowned
collection = persistenceContext.UseUnownedCollection(new CollectionKey(persister, key, entityMode));
if (collection == null)
{
// create a new collection wrapper, to be initialized later
collection = Instantiate(session, persister, key);
collection.Owner = owner;
persistenceContext.AddUninitializedCollection(persister, collection, key);
// some collections are not lazy:
if (InitializeImmediately(entityMode))
{
session.InitializeCollection(collection, false);
}
else if (!persister.IsLazy)
{
persistenceContext.AddNonLazyCollection(collection);
}
if (HasHolder(entityMode))
{
session.PersistenceContext.AddCollectionHolder(collection);
}
}
}
collection.Owner = owner;
return collection.GetValue();
}