Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Question about cross module dataproviderQuestion about cross module dataprovider
Previous
 
Next
New Post
9/10/2007 9:30 AM
 

After posting the following on the Subsonic Forums, I figured the info may be of use to other DotNetNuke developers seeing as how it is more DNN related than Subsonic related. Additionally, if anyone else has developed with Subsonic, and would like to share their own experiences/practices when developing DotNetNuke modules, that would be great too!

Here is a link to my reply on the SubSonic Community Forums to a thread on how to incorporate SubSonic DAL into a DNN Module without having to modify the web.config file. I figured it would be useful here because I had a bit of a time figuring this out.

To start off, if you haven't seen or played with the Club Starter Kit, (http://www.codeplex.com/ClubStarterKit), check it out. I believe it offers one of the nicest non-DotNetNuke starter kits out there, and has a lot of great mini applications that would make nice additions to DotNetNuke, including a very nice photo album, team/statistics tracking application, blog, calendar, news, and more. All of which is wrapped around a very nice Subsonic DAL, which by the way uses the separate assembly approach and thus offers the best example for how to approach creating a Subsonic DAL for DotNetNuke.

To recap what I did (for my test app):

Following the practice I found in the Club Starter Kit, I created a new Class Library project, named it ACIA.Data, added this to my DotNetNuke 'classic' web application project solution (which includes the BuildSupport assembly which compiles all assemblies into the web site's \Bin folder... another topic but important for module developers). For each suite of modules I develop, I always start with an architecture whereby I have my Business code in one class and reference this from each module needing to access the database. My new architecture retains the business class, and possibly the BusinessClass.SqlDataProvider class associated with theBusiness class, but adds the new 'Data' Assembly for all Subsonic data access calls like so:

Solution DotNetNuke.ACIA
|_  ACIA.Business:  Controller & Entity Classes Generated by Codesmith... Custom Controllers are named EntityManager..
|_  ACIA.Business.SqlDataProvider  SqlDataProvider generated by Codesmith (mostly).
|_  ACIA.Data: Subsonic DAL Assembly, generated with Subsonic.exe.
|_  ACIA.Database: SQL Database project to store scripts, etc.
|_  ACIA.Org: Actual Module, Web Application project. 

Then, I set up the Subsonic Command line tool as per instructions in the Club Starter Kit (there is also a great video on this on the Subsonic web site) and generated my code into the \Generated folder just like Club Starter Kit. Another upside to this method is that only a single app.config file necessary in the DAL assembly's root folder.

In my case, I wanted to limit the amount of code I generated to the objects in my module, so my entire app.config looked like:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <configSections>

    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/>

  </configSections>

   

  <connectionStrings>

    <add name="SiteSqlServer" connectionString="Data Source=.; Initial Catalog=DotNetNuke4;Integrated Security=True" providerName="System.Data.SqlClient" />

    <!--AttachDBFileName-->

  </connectionStrings>

  <SubSonicService defaultProvider="SiteSqlServer">

    <providers>

      <clear/>

      <add name="SiteSqlServer" type="SubSonic.SqlDataProvider, SubSonic"

           connectionStringName="SiteSqlServer" fixPluralClassNames="false"

           spClassName="SPs" generatedNamespace="Database"

           stripTableText="ACIA_"

           includeTableList="ACIA_Committee,ACIA_Media_Files,ACIA_Meeting, ACIA_MeetingCommittee,ACIA_MeetingRSVP,ACIA_Organization,ACIA_UserOrganization"

           includeProcedureList=""

           viewStartsWith=""

           />

    </providers>

  </SubSonicService>

</configuration>

Once code generation was working OK, I created a new class in my ACIA.Data project ... named it Application ... Created new method in the class InitializeProvider:

Imports SubSonic

Imports System.Configuration

 

Public Class Application

    Public Shared Sub InitializeProvider()

        DataService.Provider = New SqlDataProvider()

        DataService.Providers = New DataProviderCollection()

        Dim provider As DataProvider = DataService.Provider

        Dim config As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection()

        config.Add("connectionStringName", ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)

        provider.Initialize("SiteSqlServer", config)

        DataService.Provider.DefaultConnectionString = ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString

        DataService.Provider.GeneratedNamespace = "Database"

        DataService.Providers.Add(provider)

    End Sub

End Class

Then in my test method in my module:

        Private Sub TestSubSonic()

            NCIGF.Data.Application.InitializeProvider()

            Dim committee As Database.Committee = New Database.Committee(CommitteeID)

            Debug.WriteLine(committee.Name)

        End Sub

 

Having to call InitializeProvider before using Subsonic isn't so bad, and ultimately could just be put into a base class in my module project and never be messed with again: the import thing here is that I made no configuration changes to my web.config and was indeed able to exercise my Subsonic Dal.

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Question about cross module dataproviderQuestion about cross module dataprovider


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out