コード例 #1
0
 public override AppDto GetById(Guid Id)
 {
     using (UnitOfNhibernate op = new UnitOfNhibernate())
     {
         op.BeginTransaction();
         SQLAppEntity entity = op.Query <SQLAppEntity>().Where(x => x.Id.Equals(Id)).FirstOrDefault();
         return(ConvertEntityToDto(entity));
     }
 }
コード例 #2
0
 public AppDto GetByName(string Name)
 {
     using (UnitOfNhibernate op = new UnitOfNhibernate())
     {
         op.BeginTransaction();
         SQLAppEntity entity = op.Query <SQLAppEntity>().Where(x => x.Name.Equals(Name)).FirstOrDefault();
         return(ConvertEntityToDto(entity));
     }
 }
コード例 #3
0
        internal static AppDto ConvertEntityToDto(SQLAppEntity entity)
        {
            AppDto result = new AppDto();

            if (entity != null)
            {
                result.Id   = entity.Id;
                result.Name = entity.Name;
            }
            return(result);
        }
コード例 #4
0
 public override void Save(AppDto dto)
 {
     using (UnitOfNhibernate op = new UnitOfNhibernate())
     {
         op.BeginTransaction();
         SQLAppEntity entity = op.Query <SQLAppEntity>().Where(x => x.Id.Equals(dto.Id)).FirstOrDefault();
         if (entity == null)
         {
             entity = new SQLAppEntity();
         }
         entity.Name = dto.Name;
         op.SaveOrUpdate(entity);
         op.Commit();
     }
 }
コード例 #5
0
        public override void Delete(AppDto dto)
        {
            using (UnitOfNhibernate op = new UnitOfNhibernate())
            {
                op.BeginTransaction();
                SQLAppEntity entity = op.Query <SQLAppEntity>().Where(x => x.Id.Equals(dto.Id)).FirstOrDefault();
                if (entity != null)
                {
                    List <SQLLogEntity> logList = op.Query <SQLLogEntity>().Where(x => x.App.Id.Equals(entity.Id)).ToList();
                    if (logList != null && logList.Count > 0)
                    {
                        foreach (SQLLogEntity log in logList)
                        {
                            op.Delete(log);
                        }
                    }
                    op.Delete(entity);

                    op.Commit();
                }
            }
        }