SubSonic and app.config in Windows Form

Like the app.config file in a Windows Form application so that these accessor classes automatically generate it in the assembly?

0


a source to share


2 answers


Yes. What you do is add a section to configSections called "SubsonicService", for example:

<configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>

      

Then add the connectionStrings branch with the connection strings that you will use in your project, for example:

<connectionStrings>
    <clear/>
    <add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>

      



Finally, you add the SubsonicService node that you added to configSections like this:

<SubSonicService defaultProvider="WheelMUDSQLite">
    <providers>
        <clear/>
        <add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
    </providers>
</SubSonicService>

      

This is where you put all your suppliers. I am using SubStage utility to generate DAL. This way you can completely disconnect your stuff from the web bits that come with Subsonic.

+1


a source


The build process should include this method:

sonic.exe generate /config "c:\myproject\App.config"

      

sonic.exe is a SubCommander utility and is included in the current release . There is no way for app.config to handle this for you directly.



One way to run the command is MSBuild . The Exec MS Build task might look something like this:

<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
  <Exec Command="sonic.exe generate /config &quot;c:\myproject\App.config&quot;" WorkingDirectory="c:\path-to-subcommander"/>
</Target>

      

I just did this, so you probably need to configure before it works for you. This command will go into your visual studio project project (i.e. Someproject.vbproj).

+1


a source







All Articles