I am try to convert the following NHibernate query using dyanmic instantiation into an IList<t> rather than an 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);
Running this I get the following error:-
Unable to cast object of type 'NHibernate.Impl.QueryImpl' to type 'System.Collections.Generic.IList`1[Domain.Model.Entities.AllName]'.
I know that I can return
IList results = Sesssion.CreateQuery(...
but my service layers expect an
IList<AllName>
How can I achieve this?