Hi Caio. Sorry take so long to answer. My source is my database.
Since most of my tables are one to one to my classes, it works very well for me. In your case I think that you could use mygeneration but should customize it a lot. Maybe not a great idea. If I have to modify one of the generated files I do it manually. Only big changes will make me generate it again. Fabio Maulo said once to me that I should design my model and make my database based on that, but I'm not prepared for that now. :) Maybe in another project. On Jan 31, 4:39 pm, caiokf <[email protected]> wrote: > Hi Cassio, > Thanks for the reply. > > Which were the inputs for your code generation? > > I particullary don't like to generate code (in this case), bo, dto, > etc from my database. That's mainly because my domain objects not > always map one-to-one to fields in a database table. That being, I > find it hard to use mygeneration, codesmith, or another tool of that > kind to generate a good domain object for me. > > Even though, as far as I think, it may be useful to generate dto's > from the domain classes (not database tables). Don't really think > about doing that in mygeneration, but the problem could be: regenerate > the dtos after every change in the domain objects. Is there a way do > to it automatically (I don't know about it)? Or maybe like Eric said, > doing it by Resharper (I have nevr written anything for resharper, and > I don't fully know what you can do with it). > > what do you think? > > On 31 jan, 16:14, CassioT <[email protected]> wrote: > > > Here is what I did. > > > 1) MyGeneration to generate business class, mapping file, dto, DAO and > > interface to DAO > > > 2) I wrote a simple code to automatically copy everything from my BO > > to my DTO. It compares every property of the two objects and if they > > have the same name and the same type it copies the BO property value > > to correspondent DTO property. > > > Don't really know it it is a good, a bad, or an acceptable idea. > > > On Jan 30, 9:17 pm, Eric Hauser <[email protected]> wrote: > > > > Now that I think about it, this would be a great Resharper plugin. > > > Generate a DTO, a class that maps it back and forth, and accompanying > > > unit tests... > > > > On Jan 30, 6:11 pm, Eric Hauser <[email protected]> wrote: > > > > > Unfortunately, there really is no good way out of manually doing the > > > > work for the DTO. I've written a mapping library to map one object to > > > > another that did custom conversions and automatic two way mappings --- > > > > but in hindsight, it just isn't worth the effort. In it really easy > > > > to debug and unit test a class that is written like: > > > > > dto.FirstName = entity.LastName; > > > > dto.LastName = entity.LastName; > > > > foreach (var phoneNumber in entity.PhoneNumbers) { ... } > > > > > although it is certainly tedious. If you are interested in mapping > > > > frameworks, I recently saw this:http://www.codeplex.com/AutoMapper, > > > > but I never looked at it so I can't comment on it. > > > > > Unless your entities have a ridiculous amount of fields, I would just > > > > consider writing the code by hand. > > > > > On Jan 30, 5:32 pm, caiokf <[email protected]> wrote: > > > > > > Thank you all for the replies. > > > > > > @Eric and Shane. > > > > > > How would it be to work with unit tests with that approach? Now I'm > > > > > using in-memory repositories for the nh entities, and it's very easy > > > > > to unit testing. Do you think I will have to put some more effort in > > > > > order to unit test my app using DTOs, or it's just a matter of habit? > > > > > > On 30 jan, 20:03, Shane C <[email protected]> wrote: > > > > > > > Agreed with Eric. I would think very carefully before pass domain > > > > > > objects back over the wire. > > > > > > > On Jan 30, 1:03 pm, Eric Hauser <[email protected]> wrote: > > > > > > > > The biggest pitfall to consider is how much data will be > > > > > > > serialized > > > > > > > when you expose your entities over WCF. For instance, you can > > > > > > > map a > > > > > > > collection that may be very large on an object and if you are not > > > > > > > lazy > > > > > > > loading, all of that data will be serialized over the web service. > > > > > > > > The answer really is "it depends", but assuming this is an large > > > > > > > project, I always consider my web service contracts to be data > > > > > > > transfer objects. Explicitly copy the data from the entities > > > > > > > onto the > > > > > > > contract. It is best to think of web service objects as messages > > > > > > > and > > > > > > > not entities. There should be a decent amount of information on > > > > > > > this > > > > > > > subject if you do some searching. > > > > > > > > On Jan 30, 1:48 pm, Fabio Maulo <[email protected]> wrote: > > > > > > > > > AFIK the only thing you must take care when you work with > > > > > > > > NH+WCF is the > > > > > > > > nh-session management for each WCF class/method. > > > > > > > > > 2009/1/30 caiokf <[email protected]> > > > > > > > > > > Hi, > > > > > > > > > > I'm starting a new project using NHibernate, and I wonder if > > > > > > > > > some of > > > > > > > > > you had experience with this kind of project: > > > > > > > > > > The project includes more than one application accessing the > > > > > > > > > same data > > > > > > > > > store (winforms and asp.net apps). > > > > > > > > > I though about using NHibernate, with Fluent NHibernate for > > > > > > > > > Mapping > > > > > > > > > and Repositories. > > > > > > > > > Now I'm thinking about expose the NHibernate domain entities > > > > > > > > > by WCF > > > > > > > > > (so the different projects could use them), and as I never > > > > > > > > > worked with > > > > > > > > > NHibernate+WCF, I would like to know of any possible pitfalls > > > > > > > > > and what > > > > > > > > > are the best practices to do so, or if anyone knows any > > > > > > > > > better suited > > > > > > > > > option. > > > > > > > > > > I would appreciate any idea. > > > > > > > > > > Thanks, > > > > > > > > > Caio > > > > > > > > > -- > > > > > > > > Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
