protected void convertPhoto(DbPhoto p, PhotoDesc pp)
 {
     pp.Id = p.Id;
     pp.Name = p.Name;
     pp.DataBytes = p.DataBytes;
     pp.IsModified = false;
 }
 public Tuple<PhotoDesc, Exception> MaintainsPhoto(PhotoDesc oPhoto)
 {
     if (oPhoto == null)
     {
         return new Tuple<PhotoDesc, Exception>(null, new ArgumentNullException());
     }
     if (!oPhoto.IsWriteable)
     {
         return new Tuple<PhotoDesc, Exception>(null, new ArgumentException());
     }
     PhotoDesc pRet = null;
     Exception err = null;
     try
     {
         using (var ctx = getContext())
         {
             DbPhoto p = findPhoto(ctx, oPhoto);
             if (p != null)
             {
                 p.Name = oPhoto.Name;
                 p.DataBytes = oPhoto.DataBytes;
                 ctx.SaveChanges();
             }
             else
             {
                 p = new DbPhoto();
                 p.Id = nextId(ctx, TAB_PHOTO);
                 p.Name = oPhoto.Name;
                 p.DataBytes = oPhoto.DataBytes;
                 ctx.DbPhotoes.Add(p);
                 ctx.SaveChanges();
             }
             pRet = new PhotoDesc();
             convertPhoto(p, pRet);
         }// ctd
     }
     catch (Exception ex)
     {
         err = ex;
     }
     return new Tuple<PhotoDesc, Exception>(pRet, err);
 }