private static DA.BinaryData ToEntity(byte[] data, DA.OKBDataContext okb, List <DA.BinaryData> binCache)
        {
            if (data == null)
            {
                return(null);
            }
            byte[] hash;
            using (SHA1 sha1 = SHA1.Create()) {
                hash = sha1.ComputeHash(data);
            }

            var cachedBinaryData = binCache.FirstOrDefault(x => x.Hash.SequenceEqual(hash));

            if (cachedBinaryData != null)
            {
                return(cachedBinaryData);
            }

            var entity = okb.BinaryDatas.FirstOrDefault(x => x.Hash.Equals(hash));

            if (entity == null)
            {
                entity = new DA.BinaryData()
                {
                    Id = 0, Data = data, Hash = hash
                };
                binCache.Add(entity);
            }

            return(entity);
        }
Example #2
0
        internal static DA.BinaryData ToEntity(byte[] data, DA.OKBDataContext okb)
        {
            if (data == null)
            {
                return(null);
            }
            byte[] hash;
            using (SHA1 sha1 = SHA1.Create()) {
                hash = sha1.ComputeHash(data);
            }
            var entity = okb.BinaryDatas.Where(x => x.Hash.Equals(hash)).FirstOrDefault();

            if (entity == null)
            {
                entity = new DA.BinaryData()
                {
                    Id = 0, Data = data, Hash = hash
                }
            }
            ;
            return(entity);
        }

        #endregion
    }
Example #3
0
 internal static DA.BinaryData ToEntity(byte[] data, DA.OKBDataContext okb) {
   if (data == null) return null;
   byte[] hash;
   using (SHA1 sha1 = SHA1.Create()) {
     hash = sha1.ComputeHash(data);
   }
   var entity = okb.BinaryDatas.Where(x => x.Hash.Equals(hash)).FirstOrDefault();
   if (entity == null)
     entity = new DA.BinaryData() { Id = 0, Data = data, Hash = hash };
   return entity;
 }
Example #4
0
    private static DA.BinaryData ToEntity(byte[] data, DA.OKBDataContext okb, List<DA.BinaryData> binCache) {
      if (data == null) return null;
      byte[] hash;
      using (SHA1 sha1 = SHA1.Create()) {
        hash = sha1.ComputeHash(data);
      }

      var cachedBinaryData = binCache.Where(x => x.Hash.SequenceEqual(hash)).FirstOrDefault();
      if (cachedBinaryData != null)
        return cachedBinaryData;

      var entity = okb.BinaryDatas.Where(x => x.Hash.Equals(hash)).FirstOrDefault();
      if (entity == null) {
        entity = new DA.BinaryData() { Id = 0, Data = data, Hash = hash };
        binCache.Add(entity);
      }

      return entity;
    }
Example #5
0
 partial void DeleteBinaryData(BinaryData instance);
Example #6
0
 partial void UpdateBinaryData(BinaryData instance);
Example #7
0
 partial void InsertBinaryData(BinaryData instance);