Esempio n. 1
0
        // Summary:
        //     Initializes a new instance of the LongUrlContext class and configure given
        //     Microsoft.EntityFrameworkCore.DbContextOptions to specify the connection string.
        private LongUrlContext GetContext()
        {
            var optionsBuilder = new DbContextOptionsBuilder <LongUrlContext>();

            optionsBuilder.UseNpgsql(Configuration["ConnectionStrings:urlshortener"]);
            LongUrlContext context = new LongUrlContext(optionsBuilder.Options);

            return(context);
        }
Esempio n. 2
0
 public UrlShortenerController(IConfiguration config)
 {
     Configuration = config;
     context       = GetContext();
 }