I am using a foreach loop
foreach(var x in items)
{
// enter code here
}
and in my code i am sending data to database suppose in my items list i have 10 records i am sending to database after sending of 5 records due to some problem sending data failed how to rollback all the data i sent to database.
is there any way to handle this situation–i am using entity data model
Use Transactions with your insertion commands. If your targeting database is SQL Server then you cause SqlTransaction with
try/catchblock, so that if an exception occurs you canRollbackthe transaction.An example from the MSDN