Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dbContext">Instance of the VideoDbContext</param>
 /// <param name="memoryCache">Instance of the IMemoryCache</param>
 public VideoDbRepository(VideoDbContext dbContext, IMemoryCache memoryCache = null)
 {
     _dbContext         = dbContext;
     _memoryCache       = memoryCache;
     _cacheEntryOptions = new MemoryCacheEntryOptions()
                          .SetSlidingExpiration(TimeSpan.FromMinutes(5));
 }
Ejemplo n.º 2
0
        public static VideoDbContext Create(string connectionString)
        {
            var optionsBuilder = new DbContextOptionsBuilder <VideoDbContext>();

            optionsBuilder.UseMySql(connectionString);

            //Ensure database creation
            var context = new VideoDbContext(optionsBuilder.Options);

            //context.Database.EnsureCreated();

            return(context);
        }