/// <summary>
 /// Creates a new <see cref="LinkRepository{TEntity, TPrimaryKey}"/>
 /// </summary>
 /// <param name="context"><see cref="DwhDbContext"/> apply performance improvements per default</param>
 /// <param name="hashFunction">any hash function reducing the hubs business-key to it's primary key</param>
 /// <param name="logger"></param>
 public LinkRepository(DwhDbContext context
                       , DataVaultHashFunction <TPrimaryKey> hashFunction
                       , IPrimaryKeyCache keyCache  = null
                       , DVKeyCaching useKeyCaching = DVKeyCaching.Disabled
                       , ILogger <LinkRepository <TEntity, TPrimaryKey, TReference> > logger = null)
     : base(context, hashFunction, logger)
 {
     UseKeyCaching = useKeyCaching;
     if (UseKeyCaching == DVKeyCaching.Enabled)
     {
         if (keyCache == null)
         {
             throw new ArgumentNullException(nameof(keyCache), $"Must provide instance of {nameof(IPrimaryKeyCache)} if parameter '{nameof(useKeyCaching)}' is not {DVKeyCaching.Disabled}");
         }
         KeyCache = keyCache;
         if (!KeyCache.KeyCacheInitialized(typeof(TEntity)))
         {
             InitializePrimaryKeyCache();
         }
         else
         {
             Logger?.LogTrace($"'{nameof(IPrimaryKeyCache)}' for type '{typeof(TEntity)}' already initialized.");
         }
     }
     else
     {
         Logger?.LogWarning($"Primary key caching was not activated. This can result in Unique-Key Constraint violations on runtime. Consider configuring '{nameof(DVKeyCaching)}{nameof(DVKeyCaching.Enabled)}'.");
     }
 }
Exemple #2
0
 public LinkTimelineRepository(DwhDbContext context
                               , DataVaultHashFunction <string> hashFunction
                               , IPrimaryKeyCache keyCache  = null
                               , DVKeyCaching useKeyCaching = DVKeyCaching.Disabled
                               , ILogger <LinkTimelineRepository <TLink, TSatelliteTimeline> > logger = null)
     : base(context, hashFunction, keyCache, useKeyCaching, logger)
 {
 }
 public HubRepository(DwhDbContext context
                      , DataVaultHashFunction <string> hashFunction
                      , IPrimaryKeyCache keyCache  = null
                      , DVKeyCaching useKeyCaching = DVKeyCaching.Disabled
                      , ILogger <HubRepository <TEntity, string, long> > logger = null)
     : base(context, hashFunction, keyCache, useKeyCaching, logger)
 {
 }
 /// <summary>
 /// Creates a new <see cref="LinkRepository{TEntity, TPrimaryKey, TReference}"/>
 /// </summary>
 /// <param name="context"><see cref="DwhDbContext"/> apply performance improvements per default</param>
 /// <param name="hashFunction">any hash function reducing the hubs business-key to it's primary key</param>
 /// <param name="logger"></param>
 public LinkTimelineRepository(DwhDbContext context
                               , DataVaultHashFunction <TPrimaryKey> hashFunction
                               , IPrimaryKeyCache keyCache  = null
                               , DVKeyCaching useKeyCaching = DVKeyCaching.Disabled
                               , ILogger <LinkTimelineRepository <TLink, TPrimaryKey, TSatelliteTimeline, TReference> > logger = null)
     : base(context, hashFunction, keyCache, useKeyCaching, logger)
 {
     DbSetTimeline = Context.Set <TSatelliteTimeline>();
 }
 private static LinkTimelineRepository <L_Link_Timeline, S_LinkTimelineEntry> GetLinkRepo(TestDwhDbContext context, IPrimaryKeyCache keyCache)
 {
     return(new LinkTimelineRepository <L_Link_Timeline, S_LinkTimelineEntry>(context, HashFunctions.MD5, keyCache, DVKeyCaching.Enabled));
 }