【发布时间】:2009-12-29 22:21:08
【问题描述】:
我正在尝试使用动态实例化将以下 NHibernate 查询转换为 IList
IList<AllName> allNames =
(IList<AllName>)Session.CreateQuery(
@"select new AllName(
name.NameId, name.FirstName, origin.OriginId, origin.Description,
name.Sex, name.Description, name.SoundEx
) from Name name join name.Origin origin")
.SetFirstResult(skip)
.SetMaxResults(pageSize);
运行这个我得到以下错误:-
无法转换类型的对象 'NHibernate.Impl.QueryImpl' 键入 'System.Collections.Generic.IList`1[Domain.Model.Entities.AllName]'。
我知道我可以回来
IList results = Sesssion.CreateQuery(...
但我的服务层需要一个
IList<AllName>
我怎样才能做到这一点?
【问题讨论】:
标签: nhibernate casting ilist