Ejemplo n.º 1
0
            /// <summary>
            /// 新增
            /// </summary>
            /// <param name="entity"></param>
            /// <returns></returns>
            public int Insert(TestDeatailInfo entity)
            {
                var result = 0;

                try
                {
                    var db = new TestDeatailDB();
                    result = db.Insert(entity);
                }
                catch (Exception ex)
                {
                    var dbExpLog = new ExpLogDB();
                    dbExpLog.Insert(new ExpLogInfo {
                        ClassName = "TestBiz.Detail", MethodName = "Insert", ErrMsg = ex.Message
                    });
                }
                return(result);
            }
Ejemplo n.º 2
0
            /// <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);
            }