From: NHibernate J. <mik...@us...> - 2006-11-13 18:04:19
|
[ http://jira.nhibernate.org/browse/NH-586?page=all ] Sergey Koshcheyev closed NH-586: -------------------------------- Resolution: Fixed Option 3 implemented in Beta2. > Alternative way to specify the type for select new > -------------------------------------------------- > > Key: NH-586 > URL: http://jira.nhibernate.org/browse/NH-586 > Project: NHibernate > Type: Improvement > Components: Core > Versions: 1.0.2 > Reporter: Dragos Nuta > > I think that everybody agrees that adding the imports to mappings is kind of cumbersome. It is difficult to maintain and the fact that they cannot be specified in a dedicate mapping file is even more annoying in my opinion. What would you think of these alternative ways to specify the type for the mapping? > 1. session.CreateQuery( "select new Dummy(o.f1, o.f2) from MyEntity o", typeof(Dummy) ).List(); > With this you can give the Type instance as a parameter > 2. session.CreateQuery<Dummy>( "select new Dummy(o.f1, o.f2) from MyEntity o").List(); > With this you can use generics to return a typed object (with a known Type) and can also be used for normal queries to return typed lists. > 3. session.CreateQuery( "select o.f1, o.f2 from MyEntity o" ).IntoDTO( typeof(Dummy) ).List(); > With this you express separately that the data will be obtained into a Dummy Type. > 4. session.CreateQuery<Dummy>("select o.f1, o.f2 from MyEntity o").List(); > With this NH can look at the select clause and if Dummy is not persistent entity can treat it as a DTO a perform a select new. > My favorite would be 1 or 3. > Or least it would be great to add imports dynamically at run-time: > sessionFactory.Imports.Add( "Dummy", typeof(Dummy) ); > What do you think? > PS: Let me know if the change would be adopted because I can start working on it. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |