示例#1
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public void SaveEntity(string keyValue, LR_Demo_OrderEntity entity, List <LR_Demo_OrderDetailEntity> lR_Demo_OrderDetailList)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    var lR_Demo_OrderEntityTmp = GetLR_Demo_OrderEntity(keyValue);
                    entity.Modify(keyValue);
                    db.Update(entity);
                    db.Delete <LR_Demo_OrderDetailEntity>(t => t.F_OrderId == lR_Demo_OrderEntityTmp.F_OrderId);
                    foreach (LR_Demo_OrderDetailEntity item in lR_Demo_OrderDetailList)
                    {
                        item.Create();
                        item.F_OrderId = lR_Demo_OrderEntityTmp.F_OrderId;
                        db.Insert(item);
                    }
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                    foreach (LR_Demo_OrderDetailEntity item in lR_Demo_OrderDetailList)
                    {
                        item.Create();
                        item.F_OrderId = entity.F_OrderId;
                        db.Insert(item);
                    }
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
示例#2
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(string keyValue, LR_Demo_OrderEntity entity, List <LR_Demo_OrderDetailEntity> lR_Demo_OrderDetailList)
 {
     try
     {
         demoOrderService.SaveEntity(keyValue, entity, lR_Demo_OrderDetailList);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }