public void SyncDatabase<Y>(int BulkSize, string table, string idColumn, Func<T, Y> create)
        {
            lock (lck)
            {
                log.Info("Updating " + table);
                DatabaseTools.Update(table, idColumn, Update.Select(create));
                var insertedCount = 0;
                log.Info("Inserting " + table);
                foreach (var list in Insert.Chunk(BulkSize))
                {
                    DatabaseTools.BulkInsert(table, list.Select(create));
                    insertedCount += list.Count();
                    log.Info("Inserted " + insertedCount + "/" + Insert.Count);
                }

                foreach (var kvp in NewlyInserted)
                {
                    AlreadyExists.Add(GetKey(kvp.Value), kvp.Value);
                }

                NewlyInserted = new Dictionary<string, T>();
                Update = new HashSet<T>();
                Insert = new List<T>();
            }
        }