private byte[] CalculateChecksumForEntityType(Type entityType) { var crcs = new List <byte[]>(); foreach (IEntityWithRedundancyCheck entity in this.Set(entityType)) { crcs.Add(entity.CRC); } var verticalChecksum = _redundancyCheckAnalyzer.CalculateHashFromMultipleCRCs(crcs); return(verticalChecksum); }
private bool IsEntityCorrupted(IQueryable entityDbSet, Type entityType) { var crcs = new List <byte[]>(); foreach (IEntityWithRedundancyCheck entity in entityDbSet.AsNoTracking()) { if (!_redundancyCheckAnalyzer.IsValid(entity)) //Encontre un registro corrupto { return(true); } crcs.Add(entity.CRC); } //Calculo el hash vertical con todos los CRC individuales y lo comparo con lo que tengo almacenado var verticalChecksum = _redundancyCheckAnalyzer.CalculateHashFromMultipleCRCs(crcs); var savedVerticalDigitCheck = this.DbContext.CheckDigits.Find(entityType.FullName); return(!verticalChecksum.SequenceEqual(savedVerticalDigitCheck.Checksum)); }