A
A
Andrei2014-02-13 02:47:13
NHibernate
Andrei, 2014-02-13 02:47:13

How to pull out deleted, added and changed records from the dataGridView, which then need to be passed to NHibernate?

Good time of the day.
There is a simple Windows Forms application which works with a DB through NHibernate.
The data is loaded into the DataGridView with the possibility of further editing:

IList<Products> productsList = dbSession.CreateCriteria(typeof(Products)).List<Products>();
            BindingList<Products> productsBindingList = new BindingList<Products>(productsList);
            productsBindingList.AllowNew = true;
            productsBindingList.AllowRemove = true;
            dataGridView.DataSource = productsBindingList;

I can't figure out how to then save the data edited by the user in the dataGridView (when the "Save" button is clicked).
Those. how to use NHibernate is clear, it is not clear how to pull out deleted, added and changed records from the dataGridView, which then need to be passed to NHibernate .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
David_KoKos, 2014-02-13
@ngelik

The DataGridView should have events for deletion from the list or editing, you just need to subscribe to these events and remember the IDs of deleted and edited products, and in the save button, take objects with the necessary IDs from the list and carry out the operations of deleting / editing objects using the hiber.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question