Skip to content

Commit 3338ed2

Browse files
committed
Fix arrays support
1 parent c6f75fb commit 3338ed2

3 files changed

Lines changed: 133 additions & 3 deletions

File tree

src/BenchmarksApps/TechEmpower/PlatformBenchmarks/Data/RawDb.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading.Tasks;
99
using Microsoft.Extensions.Caching.Memory;
1010
using Npgsql;
11+
using NpgsqlTypes;
1112

1213
// ReSharper disable UseAwaitUsing
1314

@@ -27,7 +28,7 @@ private readonly MemoryCache _cache
2728
public RawDb(AppSettings appSettings)
2829
{
2930
#if NET8_0_OR_GREATER
30-
_dataSource = new NpgsqlSlimDataSourceBuilder(appSettings.ConnectionString).Build();
31+
_dataSource = new NpgsqlSlimDataSourceBuilder(appSettings.ConnectionString).EnableArrays().Build();
3132
#elif NET7_0
3233
_dataSource = NpgsqlDataSource.Create(appSettings.ConnectionString);
3334
#else
@@ -221,8 +222,8 @@ public async Task<World[]> LoadMultipleUpdatesRows(int count)
221222
var update = "UPDATE world w SET randomnumber = u.new_val FROM (SELECT unnest($1) as id, unnest($2) as new_val) u WHERE w.id = u.id";
222223

223224
using var updateCmd = new NpgsqlCommand(update, connection);
224-
updateCmd.Parameters.Add(new NpgsqlParameter<int[]> { TypedValue = ids });
225-
updateCmd.Parameters.Add(new NpgsqlParameter<int[]> { TypedValue = numbers });
225+
updateCmd.Parameters.Add(new NpgsqlParameter<int[]> { TypedValue = ids, NpgsqlDbType = NpgsqlDbType.Array | NpgsqlDbType.Integer });
226+
updateCmd.Parameters.Add(new NpgsqlParameter<int[]> { TypedValue = numbers, NpgsqlDbType = NpgsqlDbType.Array | NpgsqlDbType.Integer });
226227

227228
await updateCmd.ExecuteNonQueryAsync();
228229

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#:sdk Aspire.AppHost.Sdk@13.0.0
2+
3+
var builder = DistributedApplication.CreateBuilder(args);
4+
5+
// Add the postgres database from Dockerfile
6+
var postgres = builder.AddDockerfile("postgres-techempower", "../../../docker/postgres-techempower")
7+
.WithEndpoint(port: 5432, targetPort: 5432, name: "tcp")
8+
.WithEnvironment("POSTGRES_USER", "benchmarkdbuser")
9+
.WithEnvironment("POSTGRES_PASSWORD", "benchmarkdbpass")
10+
.WithEnvironment("POSTGRES_DB", "hello_world");
11+
12+
var postgresEndpoint = postgres.GetEndpoint("tcp");
13+
var connectionString = ReferenceExpression.Create($"Server={postgresEndpoint.Property(EndpointProperty.Host)};Port={postgresEndpoint.Property(EndpointProperty.Port)};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass");
14+
15+
// Add all TechEmpower benchmark applications
16+
// Note: BlazorSSR, Minimal, Mvc only support net8.0. MvcFull targets .NET Framework 4.8.
17+
// PlatformBenchmarks and RazorPages support net8.0;net9.0 multi-targeting.
18+
19+
builder.AddProject("blazorssr", "BlazorSSR/BlazorSSR.csproj")
20+
.WaitFor(postgres)
21+
.WithEnvironment("ConnectionString", connectionString)
22+
.WithUrls(context =>
23+
{
24+
var http = context.GetEndpoint("http");
25+
if (http is not null)
26+
{
27+
context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" });
28+
context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" });
29+
context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" });
30+
context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" });
31+
}
32+
});
33+
34+
builder.AddProject("minimal", "Minimal/Minimal.csproj")
35+
.WaitFor(postgres)
36+
.WithEnvironment("ConnectionString", connectionString)
37+
.WithUrls(context =>
38+
{
39+
var http = context.GetEndpoint("http");
40+
if (http is not null)
41+
{
42+
context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" });
43+
context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" });
44+
context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" });
45+
context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" });
46+
}
47+
});
48+
49+
builder.AddProject("mvc", "Mvc/Mvc.csproj")
50+
.WaitFor(postgres)
51+
.WithEnvironment("ConnectionString", connectionString)
52+
.WithUrls(context =>
53+
{
54+
var http = context.GetEndpoint("http");
55+
if (http is not null)
56+
{
57+
context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" });
58+
context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" });
59+
context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" });
60+
context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" });
61+
}
62+
});
63+
64+
builder.AddProject("platformbenchmarks", "PlatformBenchmarks/PlatformBenchmarks.csproj")
65+
.WaitFor(postgres)
66+
.WithEnvironment("ConnectionString", connectionString)
67+
.WithArgs("--framework", "net9.0")
68+
.WithArgs("-p:IsDatabase=true")
69+
.WithEnvironment("DATABASE", "PostgreSql")
70+
.WithUrls(context =>
71+
{
72+
var http = context.GetEndpoint("http");
73+
if (http is not null)
74+
{
75+
context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" });
76+
context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" });
77+
context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" });
78+
context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" });
79+
}
80+
});
81+
82+
builder.AddProject("razorpages", "RazorPages/RazorPages.csproj")
83+
.WaitFor(postgres)
84+
.WithEnvironment("ConnectionString", connectionString)
85+
.WithArgs("--framework", "net9.0")
86+
.WithUrls(context =>
87+
{
88+
var http = context.GetEndpoint("http");
89+
if (http is not null)
90+
{
91+
context.Urls.Add(new() { Url = $"{http.Url}/plaintext", DisplayText = "plaintext" });
92+
context.Urls.Add(new() { Url = $"{http.Url}/json", DisplayText = "json" });
93+
context.Urls.Add(new() { Url = $"{http.Url}/fortunes", DisplayText = "fortunes" });
94+
context.Urls.Add(new() { Url = $"{http.Url}/updates/20", DisplayText = "updates" });
95+
}
96+
});
97+
98+
builder.Build().Run();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"https": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "https://localhost:17005;http://localhost:15223",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21012",
13+
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23127",
14+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22253"
15+
}
16+
},
17+
"http": {
18+
"commandName": "Project",
19+
"dotnetRunMessages": true,
20+
"launchBrowser": true,
21+
"applicationUrl": "http://localhost:15223",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development",
24+
"DOTNET_ENVIRONMENT": "Development",
25+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19080",
26+
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18252",
27+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20285"
28+
}
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)