Hi @Paul and @James, I decided to use SetResultTransformer, and it's working fine now! Something like this:
var result = Session.CreateQuery("select o.Id as Id, o.Date as Date, o.Total as Total, o.Customer.Name as Name, o.Customer.Phone as Phone from Order o") .SetResultTransformer(Transformers.AliasToBean(typeof(AnuncioDto))) .List<OrderDto>(); It works fine, but I don't know if this is the better sollution! Thanks On Sun, Oct 17, 2010 at 5:51 AM, James Gregory <jagregory....@gmail.com>wrote: > I think the issue is this: ClassMap<MyDto> > > I believe the Import method has to be called from within a ClassMap for an > entity, not one specifically for the DTO. > > On Sun, Oct 17, 2010 at 6:05 AM, Paul Batum <paul.ba...@gmail.com> wrote: > >> I'm not familiar with this feature so I can't give specific advice, but >> have you checked the generated xml to see if the import element is being >> generated correctly? See here for info on how to export the xml: >> http://wiki.fluentnhibernate.org/Fluent_configuration#Exporting_mappings >> >> >> On Wed, Oct 13, 2010 at 12:08 PM, Felipe Oriani <fbori...@gmail.com>wrote: >> >>> Hi friends! >>> >>> I'm doing a HQL command with DTO to get only necessary fields, something >>> like this: >>> >>> "select new MyDto(d.Sector, d.Phone, d.Customer.Name, d.Customer.Email) >>> from DomainObject d" >>> >>> But, NHibernate throws an expcetion of >>> type Antlr.Runtime.MismatchedTreeNodeException says something about my HQL >>> command. >>> I found this tutorial on web: http://goo.gl/zLXD and it say to map the >>> Dto, like this: >>> >>> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <import class= >>> "Juna.GraduateProfileDTO,Juna"/> </hibernate-mapping> >>> >>> I'm using Fluent NHibernate and I tried to make a class like this: >>> >>> public class MyDtoMap : ClassMap<MyDto> >>> { >>> public MyDtoMap() >>> { >>> ImportType<MyDto>(); >>> } >>> } >>> >>> but does not work! >>> >>> How can I do this with Fluent NHibernate ? >>> >>> Thanks >>> >>> Cheers >>> >>> >>> -- >>> ______________________________________ >>> Felipe B. Oriani >>> @felipeoriani <http://www.twitter.com/felipeoriani> | >>> felipeoriani.com.br | fbori...@gmail.com >>> >>> "...Trabalhe quanto puder, tornando-se útil quanto possível..." , por >>> André Luiz >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Fluent NHibernate" group. >>> To post to this group, send email to fluent-nhibern...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/fluent-nhibernate?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Fluent NHibernate" group. >> To post to this group, send email to fluent-nhibern...@googlegroups.com. >> To unsubscribe from this group, send email to >> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/fluent-nhibernate?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To post to this group, send email to fluent-nhibern...@googlegroups.com. > To unsubscribe from this group, send email to > fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en. > -- ______________________________________ Felipe B. Oriani @felipeoriani <http://www.twitter.com/felipeoriani> | felipeoriani.com.br | fbori...@gmail.com "...Trabalhe quanto puder, tornando-se útil quanto possível..." , por André Luiz -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibern...@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.