示例#1
0
 public void Dispose()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         context.Dispose();
     }
 }
示例#2
0
 public int Commit()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.SaveChanges());
     }
 }
示例#3
0
 public IEnumerable <Skill> GetAll()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Skills.AsNoTracking().ToList());
     }
 }
示例#4
0
 public IEnumerable <Experience> GetAll()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Experience.AsNoTracking().ToList());
     }
 }
示例#5
0
 public Education Read(int id)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Education.AsNoTracking().SingleOrDefault(e => e.Id == id));
     }
 }
示例#6
0
 public Skill Read(int id)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Skills.AsNoTracking().SingleOrDefault(e => e.Id == id));
     }
 }
示例#7
0
 public IEnumerable <Education> GetAll()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Education.AsNoTracking().ToList());
     }
 }
示例#8
0
 public Experience Read(int id)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         var experience = context.Experience.AsNoTracking().SingleOrDefault(e => e.Id == id);  //WITH NO LOCK
         return(experience);
     }
 }
示例#9
0
 public Project Create(Project project)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         project.Id = context.Projects.Max(p => p.Id) + 1;
         context.Projects.Add(project);
         context.SaveChanges();
         return(project);
     }
 }
示例#10
0
 public Experience Create(Experience experience)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         experience.Id = context.Experience.Max(e => e.Id) + 1;
         context.Experience.Add(experience);
         context.SaveChanges();
         return(experience);
     }
 }
示例#11
0
 public Education Update(Education education)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         var entity = context.Education.Attach(education);
         entity.State = EntityState.Modified;
         context.SaveChanges();
         return(entity.Entity);
     }
 }
示例#12
0
 public Project Update(Project project)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         var entity = context.Projects.Attach(project);
         entity.State = EntityState.Modified;
         context.SaveChanges();
         return(entity.Entity);
     }
 }
示例#13
0
 public Experience Update(Experience experience)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         var entity = context.Experience.Attach(experience);
         entity.State = EntityState.Modified;
         context.SaveChanges();
         return(entity.Entity);
     }
 }
示例#14
0
 public Skill Update(Skill skill)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         var entity = context.Skills.Attach(skill);
         entity.State = EntityState.Modified;
         context.SaveChanges();
         return(entity.Entity);
     }
 }
示例#15
0
 public Education Create(Education education)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         education.Id = context.Education.Max(e => e.Id) + 1;
         context.Education.Add(education);
         context.SaveChanges();
         return(education);
     }
 }
示例#16
0
 public Skill Create(Skill skill)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         skill.Id = context.Skills.Max(s => s.Id) + 1;
         context.Skills.Add(skill);
         context.SaveChanges();
         return(skill);
     }
 }
示例#17
0
 public void Delete(Experience experience)
 {
     if (experience != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Experience.Remove(experience);
             context.SaveChanges();
         }
     }
 }
示例#18
0
 public void Delete(Education education)
 {
     if (education != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Education.Remove(education);
             context.SaveChanges();
         }
     }
 }
示例#19
0
 public void Delete(Skill skill)
 {
     if (skill != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Skills.Remove(skill);
             context.SaveChanges();
         }
     }
 }
示例#20
0
 public void Delete(Project project)
 {
     if (project != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Projects.Remove(project);
             context.SaveChanges();
         }
     }
 }