Menu

DataRowState functionality

aappddeevv
2006-05-31
2013-03-07
  • aappddeevv

    aappddeevv - 2006-05-31

    I started using nhibernate but noticed there were good data binding helpers for nhibernate POD object lists (e.g. from a Criteria method call).

    I looked through the code in ObjectViews.  It was not apparent that it could help me do the following without any changes to my POD object structure or nhibernate subclassing.  I need to have long conversation ability while users are editing the data in my application.

    Can someone help point the way?

    Requirements:
    a) Provide the ability to roll-back at the UI layer, changes to objects.  Think of a BindingNavigator with a "Reset" button to reset all object changes being edited in a DataGridView  I did see IEditableObject functionality but this is only used during the actual edit cycle versus after editing multiple objects then calling reset on all of them (like a RejectChanges() on a datatable.  Since I have long conversations, I saw recommendations to avoid nhibernate transactions to do this.

    b) Allow me to understand which objects are new, deleted (but not use ISession.Delete() until I am ready) or have been changed using something like a DataRowState mechanism.  Calling AcceptChanges would be nice.  One could subclass the BindingSource object and trap the add, delete, changed events, but there is no state information kept.  I was hoping ObjectViews had some of this builtin already.  Also, this would not allow me to  automatically create different versions of the object in the same spirit of DataTable and DataRowState.

    Thoughts?  I know this is slightly different than the ObjectView intended functionality.

     
    • aappddeevv

      aappddeevv - 2006-05-31

      Thats....there were [not any] good...

       
    • marcelo hamra

      marcelo hamra - 2006-06-03

      I have the same requirements that you have for my application. There's no support for such things in objectviews, so I used the traditional Dataset for databindigs with those requirements. One thing that helped me a lot is the CreateDatatable method to populate those datasets. The way I use nhibernate-objectviews-dataset is:
      1. query DB using hibernate
      2. assign retrieved collection to objectviews.Datasource
      3. merge dataset datatables using objectviews.CreateTable()
      4.let user make changes to data
      5. process changes using dataset's getchanges()

      Pay special attention to detached-transient objects if you use hibernate's session.saveorupdate()

      Regards.
      Marcelo

       
      • aappddeevv

        aappddeevv - 2006-06-05

        Thanks.  I'll look into that.

         

Log in to post a comment.

MongoDB Logo MongoDB