you don't need to define a mapping type for your DTO, if you have a mapping it is not a DTO it is an entity.
You should put a line to import the DTO into the mapping without declaring the mapping and do the select new, like <*import* class="MyNamespace.MyDTO, MyAssembly"> Another option is doing the query without declaring new and use Transformers.AliasToBean, then you should set the name of each Alias in the HQL to match the DTO. If you look for uNHAddins you have positionaltobeantransformer, which you can use to set the DTO by position of the results and not alias...another option. In none of these options you should define the DTO in the mappings for sure. Gustavo. On Thu, Oct 30, 2008 at 3:14 AM, Josh Berke <[EMAIL PROTECTED]> wrote: > What's the experts opinions on the best way to create a DTO in the latest > released nHibernate (or the latest dev build if different). I've just > finished implementing a select new query and some of the things I wasn't to > found of include: > > - Have to create a new DTO object which pollutes my domain. I needed a > DTO since this entity also has a binary document with it which I don't want > to load unless we really need it so the DTO is handy to populate the UI. I > wonder how this might change with the DLR if at all... I also don't think > criteria and projections will help. > - Have to add a new mapping to import this type in nHibernate. > - Getting the syntax right was a real pain for a novice like me. Main > issue was just making sure I was referring to the classes and not the > tables. Its so close to SQL i keep forgetting this one. > > The way I solved these was to define a common interface that my DTO and > entity object share which in my case since they are both the same heirarchy > works. I then stuffed my DTO back in the library with all dao's which kept > the domain clean. > > Anyways curious on your thoughts. > > Josh > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
