コード例 #1
0
 public List <Contact> Find(ISpecification <Contact> specification)
 {
     using (var unitOfWork = new UnitOfWorkScope <ContactDBContext>(UnitOfWorkScopePurpose.Reading))
     {
         return(unitOfWork.DbContext.Contacts.Where(specification.SearchFunction).ToList());;
     }
 }
コード例 #2
0
 public void Delete(Guid entityId)
 {
     using (var unitOfWork = new UnitOfWorkScope <ContactDBContext>(UnitOfWorkScopePurpose.Reading))
     {
         unitOfWork.DbContext.Contacts.Remove(GetById(entityId));
     }
 }
コード例 #3
0
 public List <Contact> GetAll()
 {
     using (var unitOfWork = new UnitOfWorkScope <ContactDBContext>(UnitOfWorkScopePurpose.Reading))
     {
         return(unitOfWork.DbContext.Contacts.ToList());
     }
 }
コード例 #4
0
 public Guid Add(Contact entity)
 {
     using (var unitOfWork = new UnitOfWorkScope <ContactDBContext>(UnitOfWorkScopePurpose.Writing))
     {
         unitOfWork.DbContext.Contacts.Add(entity);
         unitOfWork.SaveChanges();
         return(entity.Id);
     }
 }