After having build the SqlMapper instance with the DomSqlMapBuilder
Replace the SqlMapper DataSource with
SqlMapper.DataSource = new PerUserDataSource( SqlMapper.DataSource );
where PerUserDataSource class is something like this
PerUserDataSource.cs
public class PerUserDataSource : DataSource { IDataSource _innerDataSource = null; public PerUserDataSource( IDataSource innerDataSource) { _innerDataSource = innerDataSource; } public override string ConnectionString { get { // build the connectionstring base on the user session setting HttpContext currentContext = HttpContext.Current; string connectionString = "data source=10.1.2.3;database=DBTest;user id=#userid#;password=#password#;"; return connectionString.Replace(currentContext.Session["userid"]).Replace(currentContext.Session["password"]); } set { /* */ } } public override IDbProvider DbProvider { get { return _innerDataSource.DbProvider ; } set { /* */ } } /* ... */ }

How can we centralize all the connection strings in the iBATIS configuration?
On 11/8/06, Gilles Bayon <ibatis.net@gmail.com> wrote:
> You can place them in the web.config/app.config
>
> <appSettings>
> <add key="database" value="first connection string" />
> <add key="databaseTest" value="2nd connection string" />
> </appSettings>
>
> and initialize a session variable "ConnectionString" that is init with the
> choice of the user and used in the per user datasource