public async Task Update(Contractor item)
        {
            using (var dataContext = new ContractorsDataContext())
            {
                dataContext.Entry(item).State = EntityState.Modified;

                await dataContext.SaveChangesAsync();
            }
        }
        public async Task Add(Contractor item)
        {
            using (var dataContext = new ContractorsDataContext())
            {
                dataContext.Contractors.Add(item);

                await dataContext.SaveChangesAsync();
            }
        }
        public async Task Expand(Contractor item)
        {
            byte[] photoRaw;

            using (var dataContext = new ContractorsDataContext())
            {
                photoRaw = await
                               (from x in dataContext.Contractors.AsNoTracking()
                               where x.Id == item.Id
                               select x.PhotoRaw).FirstAsync();
            }

            item.PhotoRaw = photoRaw;
        }
 public async Task <IEnumerable <Contractor> > GetItems()
 {
     using (var dataContext = new ContractorsDataContext())
     {
         return(await(from x in dataContext.Contractors.AsNoTracking()
                      select new Contractor
         {
             Id = x.Id,
             Name = x.Name,
             Description = x.Description,
             Email = x.Email,
             Phone = x.Phone,
             Web = x.Web,
             Address = x.Address,
             HasLazyPhoto = x.HasLazyPhoto
         }).ToListAsync());
     }
 }