Class SqlServerConnectionProfile
- Namespace
- ItTiger.TigerQuery.Core
- Assembly
- ItTiger.TigerQuery.Core.dll
Represents a mutable named SQL Server connection profile that can be persisted
by SqlServerConnectionStore.
public sealed class SqlServerConnectionProfile
- Inheritance
-
SqlServerConnectionProfile
- Inherited Members
Remarks
Loading or finding a profile returns a detached mutable object. Changes are persisted only after calling AddOrUpdate(SqlServerConnectionProfile) or Save(IEnumerable<SqlServerConnectionProfile>).
Application metadata is independent of the generated connection string and must not contain secrets.
Constructors
SqlServerConnectionProfile()
Initializes an empty mutable connection profile.
public SqlServerConnectionProfile()
Properties
ApplicationIntent
Gets or sets the optional read-write or read-only application intent.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ApplicationIntentOption? ApplicationIntent { get; set; }
Property Value
Authentication
Gets or sets the authentication mechanism.
public AuthenticationType Authentication { get; set; }
Property Value
ConnectTimeout
Gets or sets the optional connection timeout in seconds.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? ConnectTimeout { get; set; }
Property Value
- int?
ConnectionStringValue
Gets or sets the complete connection string used instead of all field-based
settings.
[JsonPropertyName("ConnectionString")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public SqlServerConnectionValue? ConnectionStringValue { get; set; }
Property Value
Database
Gets or sets the optional initial database.
[JsonIgnore]
public string? Database { get; set; }
Property Value
Remarks
Null, empty, or whitespace values produce a server-level connection.
DatabaseValue
Gets or sets the optional literal or external initial catalog.
[JsonPropertyName("Database")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public SqlServerConnectionValue? DatabaseValue { get; set; }
Property Value
Encrypt
Gets or sets the transport encryption policy.
public EncryptOption Encrypt { get; set; }
Property Value
EncryptedPassword
Gets or sets the persisted protected-password value.
public string? EncryptedPassword { get; set; }
Property Value
Remarks
Its interpretation is identified by PasswordEncryption.
Applications normally let an IConnectionPasswordProtector manage it.
MaxPoolSize
Gets or sets the optional maximum connection-pool size.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? MaxPoolSize { get; set; }
Property Value
- int?
Metadata
Gets opaque, application-owned string metadata. Keys are compared ordinally and are
not normalized or interpreted by the shared connection library. Do not store
secrets in metadata.
[JsonIgnore]
public IReadOnlyDictionary<string, string> Metadata { get; }
Property Value
MinPoolSize
Gets or sets the optional minimum connection-pool size.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? MinPoolSize { get; set; }
Property Value
- int?
MultiSubnetFailover
Gets or sets whether multi-subnet failover is enabled.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? MultiSubnetFailover { get; set; }
Property Value
- bool?
Name
Gets or sets the store-unique profile name.
public string Name { get; set; }
Property Value
Options
Gets or sets free-form connection-string options supplied through the
--opt key=value
escape hatch. Applied through SqlConnectionStringBuilder so its
own validation and normalization handle unknown keys and conflicts.[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, string>? Options { get; set; }
Property Value
PasswordEncryption
Gets or sets how EncryptedPassword is protected.
public PasswordEncryptionType PasswordEncryption { get; set; }
Property Value
PasswordValue
Gets or sets an explicitly persisted literal or external password value.
[JsonPropertyName("Password")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public SqlServerConnectionValue? PasswordValue { get; set; }
Property Value
Remarks
CLI commands accept only the external-reference form. Existing prompted-password
behavior continues to use PlainPassword and
EncryptedPassword so old stores and password protectors remain
compatible.
PersistSecurityInfo
Gets or sets whether security-sensitive information remains available after opening.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? PersistSecurityInfo { get; set; }
Property Value
- bool?
PlainPassword
Gets or sets the in-memory plain-text password.
[JsonIgnore]
public string? PlainPassword { get; set; }
Property Value
Remarks
This property is excluded from JSON. The active password protector may set
or clear it during store load/save operations.
Pooling
Gets or sets whether SqlClient connection pooling is enabled.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Pooling { get; set; }
Property Value
- bool?
Server
Gets or sets the literal SQL Server host, instance, or endpoint.
[JsonIgnore]
public string Server { get; set; }
Property Value
Remarks
Assigning a literal replaces any ServerValue reference. When the
persisted value is external this compatibility property returns an empty string;
use ServerValue to inspect the reference.
ServerValue
Gets or sets the literal or external server value.
[JsonPropertyName("Server")]
public SqlServerConnectionValue ServerValue { get; set; }
Property Value
TrustServerCertificate
Gets or sets whether to trust the server certificate. Null leaves it unset; it is always
excluded under Strict.
public bool? TrustServerCertificate { get; set; }
Property Value
- bool?
Username
Gets or sets the literal SQL login name used by SQL-password authentication.
[JsonIgnore]
public string? Username { get; set; }
Property Value
UsernameValue
Gets or sets the optional literal or external SQL login name.
[JsonPropertyName("Username")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public SqlServerConnectionValue? UsernameValue { get; set; }
Property Value
UsesFullConnectionString
Gets whether this profile uses complete connection-string mode.
[JsonIgnore]
public bool UsesFullConnectionString { get; }
Property Value
Methods
BuildConnectionString(SqlServerExternalValueResolutionOptions?)
Builds the SqlClient connection string represented by this profile.
public string BuildConnectionString(SqlServerExternalValueResolutionOptions? externalValues = null)
Parameters
externalValuesSqlServerExternalValueResolutionOptions- Optional readers used only for external references; null uses the process environment and UTF-8 file reads.
Returns
- string
- The normalized connection string.
Exceptions
- ArgumentException
- A free-form option name or value is rejected by SqlConnectionStringBuilder.
BuildConnectionStringBuilder(SqlServerExternalValueResolutionOptions?)
Builds a SqlClient connection-string builder from the current profile.
public SqlConnectionStringBuilder BuildConnectionStringBuilder(SqlServerExternalValueResolutionOptions? externalValues = null)
Parameters
externalValuesSqlServerExternalValueResolutionOptions- Optional readers used only for external references; null uses the process environment and UTF-8 file reads.
Returns
- SqlConnectionStringBuilder
- A new builder that the caller may modify independently.
Remarks
A null or whitespace database is omitted. Strict encryption omits TrustServerCertificate. Entries in Options are applied last and may override first-class properties.
SQL-password authentication uses PlainPassword, not the persisted EncryptedPassword.
Exceptions
- ArgumentException
- A free-form option name or value is rejected by SqlConnectionStringBuilder.
DescribeConnectionString()
Returns a safe full-connection-string description.
public string? DescribeConnectionString()
Returns
DescribeDatabase()
Returns the safe database display without resolving a reference.
public string? DescribeDatabase()
Returns
DescribeServer()
Returns the safe server display without resolving a reference.
public string DescribeServer()
Returns
DescribeUsername()
Returns the safe username display without resolving a reference.
public string? DescribeUsername()
Returns
IsSensitiveConnectionStringOption(string)
Determines whether a connection-string option value must be redacted.
public static bool IsSensitiveConnectionStringOption(string key)
Parameters
keystring
Returns
RemoveMetadata(string)
Removes one application-owned metadata value, if present.
public bool RemoveMetadata(string key)
Parameters
keystring- The non-empty, case-sensitive key.
Returns
Remarks
Keys in TigerQuery's reserved
ittiger.e2e.* namespace are rejected; only
TigerQuery-owned operations may remove them. Call
AddOrUpdate(SqlServerConnectionProfile) to persist the change.Exceptions
- ArgumentException
keyis null or empty. The parameter name iskey.
SetMetadata(string, string)
Adds or replaces one application-owned metadata value.
public void SetMetadata(string key, string value)
Parameters
keystring- The non-empty, case-sensitive key.
valuestring- The opaque string value; an empty value is permitted.
Remarks
Keys and values are not trimmed or normalized. Keys in TigerQuery's reserved
ittiger.e2e.* namespace are rejected; only TigerQuery-owned operations may
write them. Call
AddOrUpdate(SqlServerConnectionProfile) to persist the change.Exceptions
- ArgumentException
keyis null or empty. The parameter name iskey.- ArgumentNullException
valueis null. The parameter name isvalue.