/// <summary> /// 新增 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Insert(TestMasterInfo entity) { var result = 0; try { //int x = 1; //int y = 0; //using(TransactionS) var dbMaster = new TestMasterDB(); int rMaster = dbMaster.Insert(entity); var dbDetail = new TestDetailDB(); int rDetail = dbDetail.Insert(new TestDetailInfo { ID = Guid.NewGuid().ToString(), MasterID = entity.ID, A = "asdfad" }); result = rMaster + rDetail; } catch (Exception ex) { var dbExpLog = new ExpLogDB(); dbExpLog.Insert(new ExpLogInfo { ClassName = "TestBiz.Master", MethodName = "Insert", ErrMsg = ex.Message }); } return(result); }
/// <summary> /// 新增 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Insert(TestMasterInfo entity) { var result = 0; try { //TestMasterInfo result = null; //int x = 1; //int y = 0; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted })) { var dbMaster = new TestMasterDB(); int rMaster = dbMaster.Insert(entity); //decimal z = x / y; var dbDteail = new TestDeatailDB(); int rDteail = dbDteail.Insert(new TestDeatailInfo { ID = Guid.NewGuid().ToString(), MasterID = entity.ID, A = "adaasad" }); result = rMaster + rDteail; scope.Complete(); } } catch (Exception ex) { var dbExpLog = new ExpLogDB(); dbExpLog.Insert(new ExpLogInfo { ClassName = "TestBiz.Master", MethodName = "Insert", ErrMsg = ex.Message }); } return(result); }