views:

13

answers:

0

Hello,

Executing the following NHibernate.Linq statement raises a "could not instantiate: Reservation001.Services.ReservationDto" NHibernate.QueryException containing an inner InvalidCast exception ("Object must implement IConvertible."):

var inOneStep = (from r in session.Linq<Models.ReservationHeader>()
    select new ReservationDto(r.Current));
return inOneStep;

However, after splitting the above into two queries, with ToList() called on the results of the first, the code executes fine.

var step1 = (from r in session.Linq<Models.ReservationHeader>()
     select r).ToList();
var step2 = from z in step1
     select new ReservationDto(z.Current);
return step2;

Why does the single statement version raise an exception?

Thank you,
Ben