This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_cache_path /var/cache/nginx/cache keys_zone=elasticsearch:10m inactive=60m; | |
upstream elasticsearch_servers { | |
least_conn; | |
server 47.4.119.33 weight=1; | |
server 159.173.202.86 weight=1; | |
server 121.161.211.146 weight=1; | |
server 119.112.63.63 weight=1; | |
server 249.165.150.187 weight=1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); | |
//1 | |
//services.AddDbContext<MyDbContext>(options => { options.UseInMemoryDatabase(Guid.NewGuid().ToString()); }); | |
services.AddDbContext<MyDbContext>(options => | |
{ | |
options.UseSqlServer(@"Server=localhost\SQLEXPRESS;Database=ODataTest;Trusted_Connection=True;"); | |
}); | |
//2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Route("api/[controller]")] | |
[ApiController] | |
public class ProductsController : ControllerBase | |
{ | |
private readonly MyDbContext _context; | |
public ProductsController(MyDbContext context) | |
{ | |
_context = context; | |
} | |
// GET api/values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyDbContext : DbContext | |
{ | |
private readonly ILoggerFactory _loggerFactory; | |
public MyDbContext(DbContextOptions<MyDbContext> options, ILoggerFactory loggerFactory) : base(options) | |
{ | |
_loggerFactory = loggerFactory; | |
} | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ |