-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from TrackableEntities/update-net-8
Upgrade to .NET 8.0
- Loading branch information
Showing
44 changed files
with
488 additions
and
559 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.0", | ||
"rollForward": "latestMajor", | ||
"allowPrerelease": true | ||
} | ||
} |
54 changes: 22 additions & 32 deletions
54
sample/ScaffoldingSample.Api/Controllers/EmployeeController.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,29 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.EntityFrameworkCore; | ||
using ScaffoldingSample.Contexts; | ||
|
||
namespace ScaffoldingSample.Api.Controllers | ||
namespace ScaffoldingSample.Api.Controllers; | ||
|
||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class EmployeeController(NorthwindSlimContext context) : ControllerBase | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class EmployeeController : ControllerBase | ||
// GET api/employee | ||
[HttpGet] | ||
public async Task<ActionResult> Get() | ||
{ | ||
private readonly NorthwindSlimContext _context; | ||
|
||
public EmployeeController(NorthwindSlimContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
// GET api/employee | ||
[HttpGet] | ||
public async Task<ActionResult> Get() | ||
{ | ||
var employees = await _context.Employees | ||
.OrderBy(e => e.LastName).ThenBy(e => e.FirstName) | ||
.Select(e => new | ||
{ | ||
e.EmployeeId, | ||
e.LastName, | ||
e.FirstName, | ||
BirthDate = e.BirthDate.GetValueOrDefault().ToShortDateString(), | ||
HireDate = e.HireDate.GetValueOrDefault().ToShortDateString(), | ||
Country = e.Country.ToString() | ||
}) | ||
.ToListAsync(); | ||
return Ok(employees); | ||
} | ||
var employees = await context.Employees | ||
.OrderBy(e => e.LastName).ThenBy(e => e.FirstName) | ||
.Select(e => new | ||
{ | ||
e.EmployeeId, | ||
e.LastName, | ||
e.FirstName, | ||
BirthDate = e.BirthDate.GetValueOrDefault().ToShortDateString(), | ||
HireDate = e.HireDate.GetValueOrDefault().ToShortDateString(), | ||
e.Country | ||
}) | ||
.ToListAsync(); | ||
return Ok(employees); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.EntityFrameworkCore; | ||
using ScaffoldingSample.Contexts; | ||
|
||
namespace ScaffoldingSample.Api | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | ||
builder.Services.AddEndpointsApiExplorer(); | ||
builder.Services.AddSwaggerGen(); | ||
builder.Services.AddControllers(); | ||
builder.Services.AddDbContext<NorthwindSlimContext>(options => | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
var connectionString = builder.Configuration.GetConnectionString(nameof(NorthwindSlimContext)); | ||
options.UseSqlServer(connectionString); | ||
}); | ||
|
||
var app = builder.Build(); | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
// Configure the HTTP request pipeline. | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); |
25 changes: 10 additions & 15 deletions
25
sample/ScaffoldingSample.Api/Properties/launchSettings.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:49638", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "api/employee", | ||
"launchUrl": "swagger", | ||
"applicationUrl": "http://localhost:5041", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"ScaffoldingSample.Api": { | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "api/employee", | ||
"applicationUrl": "http://localhost:5000", | ||
"launchUrl": "swagger", | ||
"applicationUrl": "https://localhost:7208;http://localhost:5041", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@SaffoldingSample.Api_HostAddress = http://localhost:5041 | ||
|
||
GET {{SaffoldingSample.Api_HostAddress}}/weatherforecast/ | ||
Accept: application/json | ||
|
||
### |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScaffoldingSample.Api", "ScaffoldingSample.Api.csproj", "{E841BA04-0CB7-46A9-8CE5-02049F3A499C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {DB5CBEB7-A02F-48C9-BD88-FC41367DDFB2} | ||
EndGlobalSection | ||
EndGlobal |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
sample/ScaffoldingSample.Embedded/ScaffoldingSample.Embedded.csproj
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
Oops, something went wrong.