我叫一个简单的实体EmployeeEntity与性质ID,Name,Age,Organisation,和Designation.我只是使用查询查询数据库
IQuery query = session.CreateQuery(
"select Name, Designation, Age, Organisation FROM EmployeeEntity " +
"group by Name, Designation, Age, Organisation");
IList<EmployeeEntity> employee = query.List<EmployeeEntity>(); // Throws error
Run Code Online (Sandbox Code Playgroud)
但在转换为我的类型时,它会抛出异常:
无法执行查询[SQL:SQL不可用]
用InnerException:
值"System.Object []"不是"NHibernateTest.EmployeeEntity"类型,不能在此通用集合中使用.
参数名称:value
虽然它使用此查询工作正常:
IQuery query = session.CreateQuery("select e FROM EmployeeEntity e group by e");
IList<EmployeeEntity> employee = query.List<EmployeeEntity>();
Run Code Online (Sandbox Code Playgroud)
但我不想选择所有列,因为我不需要它们.