ModelContext.Connection.Open();
using (var tx = ModelContext.Connection.BeginTransaction())
{
try
{
// do stuff...
tx.Commit();
return true;
}
catch
{
tx.Rollback();
throw;
}
finally
{
if (ModelContext.Connection != null)
ModelContext.Connection.Close();
}
}
No comments:
Post a Comment