private void SaveData <T>(int logId, IEnumerable <T> importList) where T : IImportEntity { using var sha1 = new SHA1Managed(); var dataList = new List <ImportData>(); foreach (var item in importList) { var jsonData = item.ToJsonData(); var checkSum = sha1.ComputeHash(Encoding.UTF8.GetBytes(jsonData)).ToHexString(); var dataExists = ImportRepository.GetLatestData(rootsmagicSourceId, item.ItemType, item.ItemId); if (dataExists?.CheckSum == checkSum) { continue; } dataList.Add(new ImportData { LogId = logId, ItemTypeId = item.ItemType, ItemId = item.ItemId, Data = jsonData, CheckSum = checkSum, }); } var insertedRows = ImportRepository.AddData(dataList); Logger.LogInformation("Importing {0}... {1}", typeof(T).Name, insertedRows); }