public void SaveLogs(List <LogEntry> logEntries) { _context.ChangeTracker.AutoDetectChangesEnabled = false; foreach (var logEntry in logEntries) { var hash = HashGenerator.GenerateKey(logEntry.DataPoints); if (_context.LogEntries.Any(x => x.HashCode.Equals(hash))) { continue; } logEntry.HashCode = hash; _context.LogEntries.Add(logEntry); _context.SaveChanges(); } }
public void TestReliableHashSmallChange() { var datapoints = new List <DataPoint>() { new DataPoint { Id = 1, Depth = 2, LogEntryId = 1, AveragePPO2 = 0.11M, Time = 10, WaterTemp = 21 }, new DataPoint { Id = 2, Depth = 2.51M, LogEntryId = 1, AveragePPO2 = 0.16M, Time = 20, WaterTemp = 21 } }; var hash = HashGenerator.GenerateKey(datapoints); Assert.AreNotEqual("82083878B4872E31C590853072F19F61", hash); }