Yes, Richard, you're totally right, and that makes perfect sense as well! Changing from "List()" to "List<object>()" solves it. Thanks for clearing that up!
Cheers! On 25 Aug, 15:14, "Richard Brown \(gmail\)" <[email protected]> wrote: > Actually, wait ... it might not be. > > To do the same as ICriteria.List() use IQueryOver.List<object>(). In your > example the List() would return a list of Student ... in ICriteria List() > would return a list of objects. > > The transformer you’re using will return (I think) a hashtable, but the > List() (in QueryOver) is trying to cast it to a Student. If you specify the > correct return type, I think it’ll work OK. > > In addition, to see an example of using alias and the AliasToBean > transformer, and specifying aliases, > see:https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibern... > (although I don’t think aliases are your problem in this instance – it might > be in the bigger query though) > > Let me know if that helps at all. > > From: Richard Brown > Sent: Thursday, August 25, 2011 8:25 AM > To: [email protected] > Subject: Re: [nhusers] AliasToEntityMap with QueryOver API in 3.2... > At first glance, it looks like a bug to me. > > If you can attach the test case to a new Jira that would be great. > > On 24 Aug 2011 20:29, "Neo" <[email protected]> wrote: > > > > > > > > > I was testing some things out using the QueryOver API and stumbled > > upon the following after simplifying it down: > > > take an entity like this: > > public class Student { > > public virtual int Id { get; protected set; } > > public virtual string Name { get; set; } > > } > > > if I do: > > session.QueryOver<Student>().TransformUsing(Transformers.AliasToEntityMap). > > List(); > > it will throw an exception saying something like: > > "The value "System.Collections.Hashtable" is not of type > > "NHibernateLab.Models.Student" and cannot be used in this generic > > collection. Parameter name: value" > > > the very same call but using criteria api: > > session.CreateCriteria<Student>().SetResultTransformer(Transformers.AliasTo > > EntityMap).List(); > > will work just fine. > > > so I tested doing: > > session.QueryOver<Student>().TransformUsing(Transformers.AliasToEntityMap). > > UnderlyingCriteria.List(); > > which actually will work just fine. > > > Is this a bug, or what's up with that? > > And,yes I know this call doesn't make much sense in this case, but > > this was as far as I could simplify it and still get it to throw an > > exception, it wasn't the original use case. > > > Cheers, > > Ted > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > mailto:nhusers%[email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
