コード例 #1
0
        public async Task SaveAsync(SubjectDebtInfo entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                using (var timeLineContext = _contextFactory.GetTimeLineContext())
                {
                    var entityModel = await timeLineContext
                                      .SubjectDebtInfos
                                      .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id));

                    if (entityModel == null)
                    {
                        entityModel = new DA.SubjectDebtInfo();
                        MapForUpdateentity(entity, entityModel);
                        await timeLineContext.SubjectDebtInfos.AddAsync(entityModel);
                    }
                    else
                    {
                        MapForUpdateentity(entity, entityModel);
                    }


                    timeLineContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
 private void MapForUpdateentity(SubjectDebtInfo entity, DA.SubjectDebtInfo daEntity)
 {
     daEntity.Id = entity.Id;
 }