How to finish the following function which accept three collection parameters for deleted, inserted and updated records and convert the collections to a DataTable
for DataAdapter
to update the table?
I found a way to convert List to DataTable at How to fill a datatable with List<T>. However, it doesn't set the insert, update and delete flags in DataTable?
void Save(
IEnumerable<int> deleted,
IEnumerable<Poco1> inserted,
IEnumerable<Poco1> updated)
{
var dt = new DataTable();
.... // Initialize dt with deleted, inserted and update?
using (var con = new SqlConnection(ConnectionStr))
{
con.Open();
var da = new SqlDataAdapter("select * from table", con);
da.Update(dt);
}
}
Or is there a better way to update the database table from these three collections? (C# 3.5)