Note: I am looking at the design patterns. After careful understanding, I found that the data access method in dnn should be a simple factory model. (I can see some books saying that it is a reflection factory, I think he uses it. net reflection technology instantiates a simple factory of objects, hope not to make mistakes again), detailed descriptions will be explained in another article. I hereby declare that we will not mislead you. (2005-06-23)
The Data Access Method of dnn core framework tables is implemented by combining singleton and abstract factory. (The data access method for each user module seems to be the same)
Singleton: Used to ensure Program There is only one data access point.
Abstract Factory: provides an interface for creating a series of related or mutually dependent objects without specifying their specific classes.
Dataprovider (Components \ providers \ data \ dataprovider. VB) is such an abstract class, which provides all the interfaces required by the system to access database operations, sqldataprovider (providers \ dataproviders \ sqldataprovider. VB) is a subclass of dataprovider, which provides specific implementation for accessing the sqlserver database. You only need to call "dataprovider. instance (). method to be used. As for the type of subclass returned, the constructor in the dataprovider class calls createprovider () to dynamically construct a specific subclass.
The configuration of the subclass that is dynamically constructed is completely set by the user in the configuration file. For example: <! -- The default provider of data is sqldataprovider. -->
< Data Defaultprovider = "Sqldataprovider" >
< Providers >
< Clear />
<! -- Provider details -->
< Add Name = "Sqldataprovider" Type = "Dotnetnuke. Data. sqldataprovider, dotnetnuke. sqldataprovider" Connectionstringname = "Sitesqlserver" Upgradeconnectionstring = "" Providerpath = "~ \ Providers \ dataproviders \ sqldataprovider \" Objectqualifier = "" Databaseowner = "DBO" />
</ Providers >
</ Data >
In this way, if you need to use the Oracle database, you only need to write an oracledataprovider subclass to implement the interfaces in dataprovider. Modify the configuration file information as follows. < Data Defaultprovider = "Oracledataprovider" >
< Providers >
< Clear />
<! -- Provider details -->
< Add Name = "Oracledataprovider" Type = "Dotnetnuke. Data. oracledataprovider, dotnetnuke. oracledataprovider" Connectionstringname = "Sitesqlserver" Upgradeconnectionstring = "" Providerpath = "~ \ Providers \ dataproviders \ oracledataprovider \" Objectqualifier = "" Databaseowner = "" />
</ Providers >
</ Data >
This data access method allows you to flexibly configure the databases used by applications. Each user module has its own dataprovider, which enables different user modules to use different databases. I am still looking at the system framework. It is not certain whether different user modules can use different databases, but I think so.
More>