Skip to content

Commit 11bc088

Browse files
committed
feat: new startup for test
1 parent eee65ee commit 11bc088

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.Extensions.Logging;
4+
using JsonApiDotNetCoreExample.Data;
5+
using Microsoft.EntityFrameworkCore;
6+
using JsonApiDotNetCore.Extensions;
7+
using System.Reflection;
8+
9+
namespace JsonApiDotNetCoreExample
10+
{
11+
/// <summary>
12+
/// This should be in JsonApiDotNetCoreExampleTests project but changes in .net core 3.0
13+
/// do no longer allow that. See https://github.com/aspnet/AspNetCore/issues/15373.
14+
/// </summary>
15+
public class ClientGeneratedIdsStartup : Startup
16+
{
17+
public ClientGeneratedIdsStartup(IWebHostEnvironment env)
18+
: base(env)
19+
{ }
20+
21+
public override void ConfigureServices(IServiceCollection services)
22+
{
23+
var loggerFactory = new LoggerFactory();
24+
var mvcBuilder = services.AddMvcCore();
25+
services
26+
.AddSingleton<ILoggerFactory>(loggerFactory)
27+
.AddLogging(builder =>
28+
{
29+
builder.AddConsole();
30+
})
31+
.AddDbContext<AppDbContext>(options => options.UseNpgsql(GetDbConnectionString()), ServiceLifetime.Transient)
32+
.AddJsonApi(options => {
33+
options.Namespace = "api/v1";
34+
options.DefaultPageSize = 5;
35+
options.IncludeTotalRecordCount = true;
36+
options.EnableResourceHooks = true;
37+
options.LoaDatabaseValues = true;
38+
options.AllowClientGeneratedIds = true;
39+
},
40+
discovery => discovery.AddAssembly(Assembly.Load(nameof(JsonApiDotNetCoreExample))),
41+
mvcBuilder: mvcBuilder);
42+
}
43+
}
44+
}

src/Examples/NoEntityFrameworkExample/Properties/launchSettings.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
}
99
},
1010
"profiles": {
11-
"NoEntityFrameworkExample": {
12-
"commandName": "Project",
11+
"IIS Express": {
12+
"commandName": "IISExpress",
1313
"launchBrowser": true,
1414
"environmentVariables": {
1515
"ASPNETCORE_ENVIRONMENT": "Development"
16-
},
17-
"applicationUrl": "http://localhost:5000/"
16+
}
1817
},
19-
"IIS Express": {
20-
"commandName": "IISExpress",
18+
"NoEntityFrameworkExample": {
19+
"commandName": "Project",
2120
"launchBrowser": true,
2221
"environmentVariables": {
2322
"ASPNETCORE_ENVIRONMENT": "Development"
24-
}
23+
},
24+
"applicationUrl": "http://localhost:5000/"
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)