I'm binding list of entities
to a data grid view like this:
var orders = context.Order.ToList(); BindingList<Order> orderList = new BindingList<Order>(orders); dataGridView1.DataSource = orderList;
User can edit or add new directly on datagridview. When user click Save
button, in order to optimize performance, I want to retrieve list of entities that has been changed/new to perform insert/update. How can I achieve this?
EDIT Define add new row to gridview:
BindinList<Order> orders = (BindingList<Order>)dataGridView1.Datasource; order.Add(new Order());
EDIT 2 Solve:
BindinList<Order> orders = (BindingList<Order>)dataGridView1.Datasource; Order order = new Order(); context.Order.Add(order); order.Add(order);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With