Hi all!

I'm developing a multi-tier application that will support multiple
tenants. Each tenant's data will be isolated in a separate database.
I'm looking for an elegant way to set the connection string during
runtime depending on the tenant's identifier (e.g. ID, name ...). My
idea is to use a custom ConnectionProvider that returns the
appropriate tenant-specific connection string, something like that:

    public class MyConnectionProvider : DriverConnectionProvider
    {
        private object tenant;

        public MyConnectionProvider(object tenant)
        {
                this.tenant = tenant;
        }

        protected override string ConnectionString
        {
            get
            {
                return BuildMyTenantConnectionString()
            }
        }
    }


On the other side I have my business methods that access the database
using AR, say for example:

public IList GetCustomers(object tenant)
{
      return Customer.FindAll();
}


Now my question is how to inject/pass the 'tenant' parameter form my
business method into my custom connection provider in order to access
the data in the correct database? Are there any best practices? Or
alternative solutions?


Thanks

Markus

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to