Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Lite/Models/ServerConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ public bool UseWindowsAuth
/// </summary>
public string? DatabaseName { get; set; }

/// <summary>
/// When true, sets ApplicationIntent=ReadOnly on the connection string.
/// Required for connecting to AG listener read-only replicas and
/// Azure SQL Business Critical / Managed Instance built-in read replicas.
/// </summary>
public bool ReadOnlyIntent { get; set; } = false;

/// <summary>
/// Display-only property for showing authentication type in UI.
/// </summary>
Expand Down Expand Up @@ -153,7 +160,8 @@ private string BuildConnectionString(string? username, string? password)
ConnectTimeout = 15,
CommandTimeout = 60,
TrustServerCertificate = TrustServerCertificate,
MultipleActiveResultSets = true
MultipleActiveResultSets = true,
ApplicationIntent = ReadOnlyIntent ? ApplicationIntent.ReadOnly : ApplicationIntent.ReadWrite
};

// Set encryption mode
Expand Down
3 changes: 3 additions & 0 deletions Lite/Windows/AddServerDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<TextBox x:Name="DatabaseNameBox" Width="250"
ToolTip="Required for Azure SQL Database. Leave empty for on-premises SQL Server."/>
</StackPanel>
<CheckBox x:Name="ReadOnlyIntentCheckBox" Content="Read-only intent (for AG listeners and readable replicas)"
Foreground="{DynamicResource ForegroundBrush}" Margin="0,6,0,0"
ToolTip="Sets ApplicationIntent=ReadOnly. Required when connecting via an AG listener or Azure failover group endpoint to route to a readable secondary."/>
</StackPanel>

<!-- Status -->
Expand Down
10 changes: 8 additions & 2 deletions Lite/Windows/AddServerDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public AddServerDialog(ServerManager serverManager, ServerConnection existing) :
FavoriteCheckBox.IsChecked = existing.IsFavorite;
DescriptionTextBox.Text = existing.Description ?? "";
DatabaseNameBox.Text = existing.DatabaseName ?? "";
ReadOnlyIntentCheckBox.IsChecked = existing.ReadOnlyIntent;

// Set authentication mode
if (existing.AuthenticationType == AuthenticationTypes.EntraMFA)
Expand Down Expand Up @@ -140,7 +141,10 @@ private SqlConnectionStringBuilder BuildConnectionBuilder()
ApplicationName = "PerformanceMonitorLite",
ConnectTimeout = 10,
TrustServerCertificate = TrustCertCheckBox.IsChecked == true,
Encrypt = ParseEncryptOption(GetSelectedEncryptMode())
Encrypt = ParseEncryptOption(GetSelectedEncryptMode()),
ApplicationIntent = ReadOnlyIntentCheckBox.IsChecked == true
? ApplicationIntent.ReadOnly
: ApplicationIntent.ReadWrite
};

if (WindowsAuthRadio.IsChecked == true)
Expand Down Expand Up @@ -342,6 +346,7 @@ private async void SaveButton_Click(object sender, RoutedEventArgs e)
AddedServer.IsFavorite = FavoriteCheckBox.IsChecked == true;
AddedServer.Description = DescriptionTextBox.Text.Trim();
AddedServer.DatabaseName = string.IsNullOrWhiteSpace(DatabaseNameBox.Text) ? null : DatabaseNameBox.Text.Trim();
AddedServer.ReadOnlyIntent = ReadOnlyIntentCheckBox.IsChecked == true;

_serverManager.UpdateServer(AddedServer, username, password);
}
Expand All @@ -358,7 +363,8 @@ private async void SaveButton_Click(object sender, RoutedEventArgs e)
EncryptMode = GetSelectedEncryptMode(),
IsFavorite = FavoriteCheckBox.IsChecked == true,
Description = DescriptionTextBox.Text.Trim(),
DatabaseName = string.IsNullOrWhiteSpace(DatabaseNameBox.Text) ? null : DatabaseNameBox.Text.Trim()
DatabaseName = string.IsNullOrWhiteSpace(DatabaseNameBox.Text) ? null : DatabaseNameBox.Text.Trim(),
ReadOnlyIntent = ReadOnlyIntentCheckBox.IsChecked == true
};

_serverManager.AddServer(AddedServer, username, password);
Expand Down
Loading