public void Update <TCachePrimaryKey, TEntity>(DeltaSnapshotCacheRowType <long, TEntity> cacheEntry) where TEntity : class, IDataSetEntity, new() { try { string sql = @" UPDATE dlta_cache_snapshot SET subscription_data_set_id = :SubscriptionDataSetId, run_id = :RunId, entity_identifier = :EntityIdentifier, entity_delta_code = :EntityDeltaCode, entity_delta_date = :EntityDeltaDate, entity_data_current = :EntityDataCurrent, entity_data_previous = :EntityDataPrevious WHERE cache_snapshot_id = :PrimaryKey "; unitOfWork.Connection.Execute(sql, new { cacheEntry.SubscriptionDataSetId, cacheEntry.RunId, cacheEntry.EntityIdentifier, cacheEntry.EntityDeltaCode, cacheEntry.EntityDeltaDate, cacheEntry.EntityDataCurrent, cacheEntry.EntityDataPrevious, cacheEntry.PrimaryKey }); } catch (Exception ex) { Console.WriteLine($"CONSUMER: {nameof(Update)} {cacheEntry.EntityIdentifier} {ex.Message}"); Console.WriteLine($"CONSUMER: {nameof(Update)} {cacheEntry.EntityIdentifier} {ex.StackTrace}"); throw; } }
public long Insert <TCachePrimaryKey, TEntity>(DeltaSnapshotCacheRowType <long, TEntity> cacheEntry) where TEntity : class, IDataSetEntity, new() { try { var cacheSnapshotId = DatabaseUtil.GetNextVal("DLTA_CACHE_SNAPSHOT_S", unitOfWork.Connection); var sql = @"INSERT INTO dlta_cache_snapshot ( cache_snapshot_id, subscription_data_set_id, run_id, entity_identifier, entity_delta_code, entity_delta_date, entity_data_current, entity_data_previous ) VALUES ( :cacheSnapshotId, :SubscriptionDataSetId, :RunId, :EntityIdentifier, :EntityDeltaCode, :EntityDeltaDate, :EntityDataCurrent, :EntityDataPrevious ) "; unitOfWork.Connection.Execute(sql, new { cacheSnapshotId, cacheEntry.SubscriptionDataSetId, cacheEntry.RunId, cacheEntry.EntityIdentifier, cacheEntry.EntityDeltaCode, cacheEntry.EntityDeltaDate, cacheEntry.EntityDataCurrent, cacheEntry.EntityDataPrevious }); return(cacheSnapshotId); } catch (Exception ex) { Console.WriteLine($"CONSUMER: {nameof(Insert)} {cacheEntry.EntityIdentifier} {ex.Message}"); Console.WriteLine($"CONSUMER: {nameof(Insert)} {cacheEntry.EntityIdentifier} {ex.StackTrace}"); throw; } }