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.0DAL Best PracticeDAL Best Practice
Previous
 
Next
New Post
8/7/2007 9:37 AM
 

Can anybody shed some light here please for creating the DAL using multiple tables for a module.

I am developing a module that maintains multiple tables. I have created an info, business class, and data provider class that maps to each of the tables. I used mygeneration to auto generate the basic classes. One question I have is when I create a stored procedure that performs a join on these tables do I have to create a seperate info, biz controller and data access classes for each procedure that uses a JOIN or is there a better way of doing this and still maintain the Dotnetnuke provider model?

Regards

Colm


Colm Ryan Director
3rd i IT and Business Services Limited

www.actravia.com
Registration and Booking Solutions for Dotnetnuke
www.3rdi.ie
IMCA Registered Management Consulting Practice. Business and IT Strategy, IT Project Management and Product Development
 
New Post
8/8/2007 4:40 AM
 

It would make sense if these Info objects represented seperate entities i.e. ItemForSaleInfo

You don't have to have a DAL class representing each table.  I regularly have a stored procedure that joins multiple tables, which populates one Info object.  For the ItemForSaleInfo example, I might pull most of the data from my products table, but I would also join the categories table with my sql query and populate the property ItemForSaleInfo.Category with that.

Also, have a look at the DAL+ links if you don't need to support multiple datasources.

Thanks

 
New Post
8/8/2007 8:58 AM
 

In the Survey module this stored procedure joins multiple tables:

create procedure {databaseOwner}{objectQualifier}GetSurvey

@SurveyID int,
@ModuleID int

as

select SurveyID,
       ModuleID,
       Question,
       ViewOrder,
       OptionType,
       'CreatedByUser' = {objectQualifier}Users.FirstName + ' ' + {objectQualifier}Users.LastName,
       CreatedDate,
       'Votes' = ( select sum(Votes) from {objectQualifier}SurveyOptions where {objectQualifier}SurveyOptions.SurveyID = {objectQualifier}Surveys.SurveyID )
from   {objectQualifier}Surveys
left outer join {objectQualifier}Users on {objectQualifier}Surveys.CreatedByUser = {objectQualifier}Users.UserID
where  SurveyID = @SurveyID
and    ModuleID = @ModuleID

GO

and this DAL mathod hydrates the SurveyInfo object:

 Public Shared Function GetSurvey(ByVal SurveyID As Integer, ByVal ModuleId As Integer) As SurveyInfo
            Dim SurveyInfo As SurveyInfo = New SurveyInfo
            Using dr As IDataReader = DataProvider.Instance().GetSurvey(SurveyID, ModuleId)
                While dr.Read
                    SurveyInfo.SurveyId = Convert.ToInt32(dr("SurveyId"))
                    SurveyInfo.ModuleId = Convert.ToInt32(dr("ModuleID"))
                    SurveyInfo.Question = Convert.ToString(dr("Question"))
                    SurveyInfo.OptionType = Convert.ToString(dr("OptionType"))
                    SurveyInfo.ViewOrder = Convert.ToInt32(ConvertNullInteger(dr("ViewOrder")))
                    SurveyInfo.Votes = Convert.ToInt32(ConvertNullInteger(dr("Votes")))
                    SurveyInfo.CreatedByUser = Convert.ToInt32(dr("CreatedByUser"))
                    SurveyInfo.CreatedDate = Convert.ToDateTime(dr("CreatedDate"))
                End While
            End Using
            Return SurveyInfo
        End Function



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DAL Best PracticeDAL Best Practice


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