Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1cc5eb8

Browse files
committed
added multiple connection string support
1 parent 9b2fddc commit 1cc5eb8

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

‎Controllers/ControllerQuery.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public ControllerQuery(IConfiguration config, ILogger<ControllerQuery> logger)
3636
string procedure = $"web.{verb}_{entityName}";
3737
_logger.LogDebug($"Executing {procedure}");
3838

39-
using(var conn = new SqlConnection(_config.GetConnectionString("DefaultConnection"))) {
39+
var connectionStringName = verb.ToLower() != "get" ? "ReadWriteConnection" : "ReadOnlyConnection";
40+
41+
using(var conn = new SqlConnection(_config.GetConnectionString(connectionStringName))) {
4042
DynamicParameters parameters = new DynamicParameters();
4143

4244
if (payload.ValueKind != default(JsonValueKind))

‎appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"AllowedHosts": "*",
1010
"ConnectionStrings": {
11-
"DefaultConnection": "Server=.database.windows.net;Database=;UID=;PWD="
11+
"ReadWriteConnection": "Server=.database.windows.net;Database=;UID=;PWD=",
12+
"ReadOnlyConnection": "Server=.database.windows.net;Database=;UID=;PWD="
1213
}
1314
}

‎azure-sql-db-dotnet-rest-api.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Dapper" Version="2.0.30" />
10-
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0" />
9+
<PackageReference Include="Dapper" Version="2.0.35" />
10+
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.1" />
1111
<PackageReference Include="System.Text.Json" Version="4.7.0" />
1212
</ItemGroup>
1313

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /