Question

The security policy at our client's production environment requires that we use separate connection to execute writes and read to and from database. We have decided to use SubSonic to generate our DAL. So I am interested in knowing if it is possible and if yes how?

Was it helpful?

Solution

You can specify the provider SubSonic is using at runtime. So you would specify the read provider (using your read connectionstring) when loading from the database and then specify the write provider (using your write connectionstring) when you want to save to it.

The following isn't tested but I think it should give you the general idea:

        SqlQuery query = new Select()
            .From<Contact>();

        query.ProviderName = Databases.ReadProvider;

        ContactCollection contacts = query.ExecuteAsCollection<ContactCollection>();
        contacts[0].FirstName = "John";
        contacts.ProviderName = Databases.WriteProvider;
        contacts.SaveAll();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top