private static ISession _session ; public IList<int> list() {using (_session = factory.Session) { IQuery querys = _session.CreateQuery(“select id from news”); return querys.List<int>(); }} private static ISessionFactory _factory; static object obj = new object(); public ISession Session { get { if (_factory == null) { lock (obj) { if (_factory == null) { Configuration cf = new Configuration().Configure(); _factory = cf.BuildSessionFactory(); } } } return _factory.OpenSession(); } }
为什么这么写调用 list() 总会报错。报的是
Could not execute query[SQL: SQL not available] 在return querys.List<int>(); 中报的,本人是nhibernate新手,请指教下。
添加回答
举报
0/150
提交
取消