This project is read-only.

Complex Configuration

Coconut Dal supports as many databases as your application needs. You can group connections into Test, Live or other environments by using a suffix, then telling Cocount Dal which suffix to use for the current application.

<CoconutDalConfigurationSection>
<Database UseSuffix="_Live">
<Connections>
<!-- connections for test environment -->
<add Name="Membership_Test" ConnectionString="Data Source=MyLocalDbServer;
Initial Catalog=CoconutMilk;Integrated Security=True;
"/> <add Name="Content_Test" ConnectionString="Data Source=MyLocalDbServer;
Initial Catalog=CoconutFlakes;Integrated Security=True;
"/> <!-- connections for live environment --> <add Name="Membership_Live" ConnectionString="Data Source=MyLiveDbServer;
Initial Catalog=CoconutMilk;Integrated Security=True;
"/> <add Name="Content_Live" ConnectionString="Data Source=MyLiveDbServer;
Initial Catalog=CoconutFlakes;Integrated Security=True;
"/> </Connections> </Database> </CoconutDalConfigurationSection>

Then, retrieve the database you need by passing the name to the Dal Constructor:

ICoconutDal dal = new SqlServerCoconutDal("Membership");

No configuration

If you manage your own connection strings and do not want to use the CoconutDalConfigurationSection, you can use this constructor:

new SqlServerCoconutDal(ConfigurationBehaviour.DoNotUseAppConfig, "Your Connection String");

Last edited May 31, 2012 at 7:19 PM by CoconutDev, version 1

Comments

No comments yet.