Per-thread ambient connection string for scoped operations that need to run against
an explicit connection without modifying every engine signature in the codebase.
Namespace:
AdvantageCMS.Data
Assembly:
AdvantageCMS.Data (in AdvantageCMS.Data.dll)
public static class SqlConnectionContext
When a connection string is pushed via
Scope(String), any
SQL
instance constructed on the same thread that has no explicit connection string of its
own will pick up the ambient value — see
GetConnectionString()()()(), where
the ambient is checked as a higher-priority fallback than
ConfigurationManager.ConnectionStrings.
Primary use case: the InitializeCSP wizard's Step 5 (BuildDomain) runs BEFORE
web.config has been written. Wrapping the work in a
Scope(String) makes every
engine-internal
new SQL() — inside
CMSDomainEngine,
CMSConfigurationEngine,
DomainManager,
AdvantageUserManager,
etc. — resolve against the wizard's Session-derived connection string instead of
crashing on the empty
ConfigurationManager.
Backed by
ThreadStaticAttribute, not
AsyncLocal:
init runs on a sync background work item, no async flow needed. If a future caller
awaits inside a scope, swap the backing field to
AsyncLocal<string> —
the public API stays identical.
Object AdvantageCMS.Data..::..SqlConnectionContext