public void Persist(DetectedChanges detectedChanges) { if (_initialized) { Initialize(); } using var connection = CreateConnection(); using var transaction = connection.BeginTransaction(); //CREATE TEMP TABLES connection.Execute(@" CREATE TABLE [#GarbageCollectables] ( [ObjectId] [bigint] NOT NULL ) CREATE TABLE [#KeyValues]( [InstanceId] [nvarchar](50) NOT NULL, [ObjectId] [bigint] NOT NULL, [Key] [nvarchar](50) NOT NULL, [Value] [nvarchar](max) NULL, [ValueType] [nvarchar](50) NULL, [Reference] [bigint] NULL ) CREATE TABLE [#RemovedEntries]( [ObjectId] [bigint] NOT NULL, [Key] [nvarchar](50) NOT NULL )", transaction: transaction); AddSerializerTypes(detectedChanges.NewSerializerTypes, connection, transaction); UpsertEntries(detectedChanges.NewEntries, connection, transaction); RemoveRemovedEntries(detectedChanges.RemovedEntries, connection, transaction); RemoveGarbageCollectables(detectedChanges.GarbageCollectableIds, connection, transaction); transaction.Commit(); }
public void Persist(DetectedChanges detectedChanges) { InvokedCount.Value++; }
public void Persist(DetectedChanges detectedChanges) { }
public void Persist(DetectedChanges detectedChanges) { var newEntries = detectedChanges.NewEntries .Select(e => { if (e.Reference.HasValue) { return (IEntry) new NewReference { EntryType = EntryType.NewReferenceEntry, ObjectId = e.ObjectId, Key = e.Key, Reference = e.Reference.Value } } ; if (e.Value == null) { return new NewNullValueEntry { EntryType = EntryType.NewNullValueEntry, ObjectId = e.ObjectId, Key = e.Key } } ; else { return new NewValueEntry { EntryType = EntryType.NewValueEntry, ObjectId = e.ObjectId, Key = e.Key, Value = new JRaw(e.Value.ToJson()), ValueType = e.Value.GetType().SimpleQualifiedName() } }; } ); IEnumerable <IEntry> removedEntries = detectedChanges.RemovedEntries .Select(e => new Removed { EntryType = EntryType.RemovedEntry, ObjectId = e.ObjectId, Key = e.Key }); IEnumerable <IEntry> garbageCollected = detectedChanges.GarbageCollectableIds .Select(gc => new GarbageCollected { EntryType = EntryType.GarbageCollectedEntry, ObjectId = gc }); IEnumerable <IEntry> serializerTypeEntries = detectedChanges.NewSerializerTypes .Select(e => new SerializerType { EntryType = EntryType.SerializerTypeEntry, ObjectId = e.ObjectId, Type = e.SerializerType.SimpleQualifiedName() }); var allJson = newEntries .Concat(removedEntries) .Concat(garbageCollected) .Concat(serializerTypeEntries) .Select(JsonConvert.SerializeObject); File.AppendAllLines(_path, allJson); }