17,740
社区成员
发帖
与我相关
我的任务
分享
public Person GetPerson(string name)
{
ISession session = SessionFactory.GetSession();//得到一个session
try
{
IQuery query = session.CreateQuery("from Person p where p.Name = " + name);
IList list = query.List();
if (list.Count < 1)
{
return null;
}
else
{
Person p = list[list.Count - 1] as Person;
return p;
}
}
catch (Exception ex)
{
throw new ApplicationException("1010 : " + ex.Message);
}
finally
{
session.Close();
}
}