【发布时间】:2011-08-31 14:26:25
【问题描述】:
以下代码有什么问题(在 NHibernate 2.1.2 中)?
public IEnumerable<EmployeeSummary> List()
{
return Session.CreateCriteria<Employee>("e")
.SetCacheable(true)
.SetProjection(Projections.ProjectionList()
.Add(Projections.Property("e.Id"), "Id")
.Add(Projections.Property("e.CurrentOffice.Id"), "CurrentOfficeId")
.SetResultTransformer(new AliasToBeanResultTransformer(typeof(EmployeeSummary)))
.List<EmployeeSummary>();
}
public class EmployeeSummary
{
public Guid Id { get; private set; }
public Guid CurrentOfficeId { get; private set; }
}
我收到以下错误: NHibernate.Exceptions.GenericADOException:无法执行查找[SQL:SQL 不可用] ----> System.InvalidCastException:无法将“EmployeeSummary”类型的对象转换为“System.Object[]”类型。
【问题讨论】:
标签: nhibernate