Hi Gustavo, very interesting your articles... i didnt see the code examples yet... but what if my Repository is using an Unit Of Working pattern ? Well, something like this:
http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/10/08/the-repository-pattern.aspx i would have to change my repositoy approach ? 2009/2/10 Gustavo Ringel <[email protected]> > I suggest you to read my posts and see the example...the idea is exactly > what you are looking for. > > > http://gustavoringel.blogspot.com/2009/02/unhaddins-persistence-conversation-part.html > > http://gustavoringel.blogspot.com/2009/02/unhaddins-persistence-conversation-part_08.html > > There you will find a link to the trunk of uNHAddins where i have the full > example. > > Gustavo. > > > On Tue, Feb 10, 2009 at 6:55 PM, Dcam <[email protected]> wrote: > >> >> I have a WinApp with a Form in which I'd like to let the user edit a >> list of Entities in a DataGridView; meaning changing existing, adding >> new ones and deleting newly added or existing entities. >> But the user should be able to discard all "his work" or save it. >> Lates version of NHibernate 2 by the way. >> >> Based on secion 10.4.1 "Long session with automatic versioning" in the >> manual(http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/ >> html_single/#transactions-optimistic<http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/%0Ahtml_single/#transactions-optimistic>), >> I do the following when opening >> the Form: >> - open a session with ISessionFactory.OpenSession() and store it in a >> class property >> - load all data with Session.Load(...) >> - disconnect the session with Session.Disconnect() >> - bind the list of entities to the a BindingSource bound to my >> DataGridView >> >> Editing the entities in the list is no problem. But unfortunately I >> can't find a way to add/attach new entity to the session without >> getting them immediately writen to the database. I just want a new >> entity to add/attache to the session, so I can let NHibernate do the >> required INSERT und UPDATE queries when I flush/commit the changes to >> the database on button_OK. >> Session.Merge and Session.Save throw an error saying that the session >> is not connected. And if I do so (what I actually don't want at this >> stage) then the new records are directly written to the database. >> Setting Session.FlushMode to FlushMode.Commit did not work. >> >> Any ideas how to do that? >> >> Thank in advance >> Daniel >> >> >> >> >> > > > > -- Paulo R. Quicoli Editor Técnico - ClubeDelphi Magazine - DevMedia --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
