This file contains hidden or 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
| [HttpGet] | |
| public async Task<ActionResult<IEnumerable<Blog>>> GetBlogs() | |
| { | |
| var connection = _context.Database.GetDbConnection(); | |
| var data = await connection.QueryAsync<Blog>("SELECT * FROM Blogs"); | |
| return data.ToList(); | |
| } |
This file contains hidden or 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 BlogsController : ControllerBase | |
| { | |
| private readonly AppContext _context; | |
| public BlogsController(AppContext context) | |
| { | |
| _context = context; | |
| } | |
| // GET: api/Blogs |
This file contains hidden or 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.Configure<CookiePolicyOptions>(options => | |
| { | |
| // This lambda determines whether user consent for non-essential cookies is needed for a given request. | |
| options.CheckConsentNeeded = context => true; | |
| options.MinimumSameSitePolicy = SameSiteMode.None; | |
| }); | |
| var connection = "Server=localhost;Port=5432;Database=Test;User Id=postgres;Password=postgres;"; |
This file contains hidden or 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 AppContext : DbContext | |
| { | |
| public AppContext(DbContextOptions<AppContext> options) | |
| : base(options) | |
| { } | |
| public DbSet<Blog> Blogs { get; set; } | |
| public DbSet<Post> Posts { get; set; } | |
| } |
This file contains hidden or 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 Post | |
| { | |
| public int PostId { get; set; } | |
| public string Title { get; set; } | |
| public string Content { get; set; } | |
| public int BlogId { get; set; } | |
| public Blog Blog { get; set; } | |
| } |
This file contains hidden or 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 Blog | |
| { | |
| public int BlogId { get; set; } | |
| public string Url { get; set; } | |
| public ICollection<Post> Posts { get; set; } | |
| } |
This file contains hidden or 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 OdbcRepository | |
| { | |
| public List<Model> Get(string name) | |
| { | |
| //Create a connection | |
| var connection = new OdbcConnection(connectionString); | |
| //Construct the query | |
| //Usually you use @parameter as the syntax for querying SQL Server | |
| //But for querying to Microsoft Access you must use ? |
This file contains hidden or 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
| server { | |
| listen 80; | |
| listen [::]:80; | |
| . . . | |
| root /var/www/laravel/public; | |
| index index.php index.html index.htm index.nginx-debian.html; | |
| server_name _; |
This file contains hidden or 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
| [Unit] | |
| Description=My ASP.NET Core | |
| [Service] | |
| WorkingDirectory=/var/www/myaspnetcore | |
| ExecStart=/usr/bin/dotnet /var/www/myaspnetcore/myaspnetcore.dll | |
| Restart=always | |
| # Restart service after 10 seconds if the dotnet service crashes: | |
| RestartSec=10 | |
| KillSignal=SIGINT |
This file contains hidden or 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
| server { | |
| listen 80; | |
| root /var/www/myaspnetcore/wwwroot; | |
| server_name _; | |
| location / { | |
| proxy_pass http://localhost:5000; | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection keep-alive; | |
| proxy_set_header Host $http_host; |
NewerOlder