本文整理汇总了C#中ISession.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.Disconnect方法的具体用法?C# ISession.Disconnect怎么用?C# ISession.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.Disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Set
/// <summary>
/// 保存ISession
/// </summary>
/// <param name="value"></param>
public void Set(ISession value)
{
if (value.IsConnected) {
value.Disconnect();
}
_session = value;
}
示例2: BuyNewComputer
public bool BuyNewComputer(Computer c)
{
bool bReturn = true;
try
{
session = sessionFactory.OpenSession();
tx = session.BeginTransaction();
session.Save(c);
tx.Commit();
}
catch(Exception ex)
{
bReturn = false;
}
finally
{
session.Flush();
session.Disconnect();
}
return bReturn;
}
示例3: BuyNewComputers
public bool BuyNewComputers(Computer[] cts)
{
bool bReturn = true;
try
{
session = sessionFactory.OpenSession();
tx = session.BeginTransaction();
for(int i=0;i<cts.Length;i++)
{
session.Save(cts[i]);
}
tx.Commit();
}
catch(Exception ex)
{
bReturn = false;
}
finally
{
session.Flush();
session.Disconnect();
}
return bReturn;
}
示例4: GetComputersByOwner
public Computer[] GetComputersByOwner(string Owner)
{
Computer[] computers = null;
IList list = null;
try
{
session = sessionFactory.OpenSession();
qry = session.CreateQuery("from Computer where Owner='"+Owner+"'");
list = qry.List();
computers = new Computer[list.Count];
list.CopyTo(computers, 0);
}
finally
{
session.Flush();
session.Disconnect();
}
return computers;
}