Entity Frameword 使用事务及批量删除
public void DeleteAll(int MasterID)
{
using (TransactionScope transaction = new TransactionScope())
{
var model = db.BudgetMaster.First(t => t.MasterID == MasterID);
db.DeleteObject(model);
int value = db.SaveChanges();
db.ExecuteStoreCommand("delete from BudgetDetail where masterid =@masterid", new SqlParameter("@masterid", MasterID));
transaction.Complete();
}
}