本文整理汇总了C#中NHibernate.OpenSession方法的典型用法代码示例。如果您正苦于以下问题:C# NHibernate.OpenSession方法的具体用法?C# NHibernate.OpenSession怎么用?C# NHibernate.OpenSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate
的用法示例。
在下文中一共展示了NHibernate.OpenSession方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getExistingOrNewSession
private ISession getExistingOrNewSession(NHibernate.ISessionFactory factory)
{
if (HttpContext.Current != null)
{
ISession session = GetExistingWebSession();
if (session == null)
{
session = openSessionAndAddToContext(factory);
}
else if (!session.IsOpen)
{
session = openSessionAndAddToContext(factory);
}
return session;
}
if (currentSession == null)
{
currentSession = factory.OpenSession();
}
else if (!currentSession.IsOpen)
{
currentSession = factory.OpenSession();
}
return currentSession;
}
示例2: openSessionAndAddToContext
private ISession openSessionAndAddToContext(NHibernate.ISessionFactory factory)
{
ISession session = factory.OpenSession();
HttpContext.Current.Items.Remove(GetType().FullName);
HttpContext.Current.Items.Add(GetType().FullName, session);
return session;
}
示例3: GroupingControlForm
public GroupingControlForm(NHibernate.ISessionFactory sessionFactory)
{
InitializeComponent();
this.session = sessionFactory.OpenSession();
tlvGroupedFiles.CanExpandGetter += x => (((tlvBranch)x).Data is SpectrumSourceGroup && ((tlvBranch)x).Children.Any());
tlvGroupedFiles.ChildrenGetter += getChildren;
tlvGroups.AspectGetter += x =>
{
var nodeTracker = ((tlvBranch) x);
var offsetCorrection = 0;
while (nodeTracker.Parent.Text != null)
{
offsetCorrection++;
nodeTracker = nodeTracker.Parent;
}
return ((tlvBranch) x).Text + new string(' ',offsetCorrection*7);
};
tlvGroups.AutoCompleteEditor = false;
tlvGroups.ImageGetter += delegate(object x) { return (((tlvBranch)x).Data is SpectrumSourceGroup) ? Properties.Resources.XPfolder_closed : Properties.Resources.file; };
ApplyDefaultGroups(null, null);
}