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
| builder.Services.AddAuthorization(options => | |
| { | |
| options.FallbackPolicy = new AuthorizationPolicyBuilder() | |
| .RequireAuthenticatedUser() | |
| .Build(); | |
| }); |
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
| # Create a new project | |
| # @name createProject | |
| POST {{HostAddress}}/api/projects | |
| Content-Type: application/json | |
| { | |
| "name": "My New Project" | |
| } | |
| ### |
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
| # Create a new project | |
| # @name createProject | |
| POST {{HostAddress}}/api/projects | |
| Content-Type: application/json | |
| { | |
| "name": "My New Project" | |
| } |
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
| using Microsoft.AspNetCore.Mvc; | |
| using System.Collections.Concurrent; | |
| namespace HTTPFileTryOut.Controllers | |
| { | |
| [ApiController] | |
| [Route("api/[controller]")] | |
| public class ProjectsController : ControllerBase | |
| { | |
| private static readonly ConcurrentDictionary<Guid, Project> Projects = new(); |
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
| { | |
| "$shared": { | |
| "ApiVersion": "v1", | |
| "ContentType": "application/json" | |
| }, | |
| "dev": { | |
| "HostAddress": "http://localhost:5221" | |
| }, | |
| "test": { | |
| "HostAddress": "https://test.site.com" |
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
| { | |
| "dev": { | |
| "ApiKey": "your-local-dev-key", | |
| "DatabaseConnection": "Server=localhost;Database=MyDb" | |
| } | |
| } |
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
| { | |
| "dev": { | |
| "HostAddress": "http://localhost:5221" | |
| }, | |
| "test": { | |
| "HostAddress": "https://test.site.com" | |
| }, | |
| "production": { | |
| "HostAddress": "https://prd.site.com" | |
| } |
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
| @HostAddress = http://localhost:5221 | |
| GET {{HostAddress}}/weatherforecast/ | |
| Accept: application/json | |
| ### |
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
| protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
| { | |
| optionsBuilder | |
| .UseSqlServer(connectionString) | |
| .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTrackingWithIdentityResolution); | |
| } |
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
| var orders = await context.Orders | |
| .AsNoTrackingWithIdentityResolution() | |
| .Include(o => o.Customer) | |
| .Where(o => o.OrderDate > DateTime.Now.AddDays(-30)) | |
| .ToListAsync(); | |
| // Now all orders that belong to the same customer | |
| // reference the same Customer instance in memory |