BlogEngine.NET Architecture and source Code Analysis series PART3: Data storage

Source: Internet
Author: User
Tags blogengine

Implementation based on provider mode

In the last article, we mainly analyzed the overall design of blogengine.net, in the latter part of the Businessbase business object of the state maintenance do some more in-depth discussion. In this article I will lead you to complete the blogengine.net of business object data storage design ideas and implementation details of the analysis.

The data storage in BlogEngine.NET is mainly implemented by using provider mode, so let's get to know provider mode first.

The provider pattern should be a design pattern that is used to solve software change problems. But the angle (or dimension) it focuses on is the separation of feature declarations from functional implementations. In general, the system's need for a function may be relatively stable (for example, each system requires the user to authenticate, this need is relatively stable), and this function of the specific implementation can be diverse (for example, you can go to the database to match the user to verify, You can also go to an XML file to match it. The provider pattern is ubiquitous in the design of. NET class libraries, such as MembershipProvider, SiteMapProvider, etc., which makes our applications more extensible, pay attention to provider can be a data Factory provider, It can also be a provider of logical processing. All we see in BlogEngine.NET is the provider of data factories, and for the providers of logical processing, you can refer to the implementation of the encryption block in Microsoft Enterprise Library Applicationblock.

It is fairly straightforward to implement this pattern in. NET because it has been implemented for us, and we only need to implement the following three steps:

1, define a class, abstract the operation we need, its base class is ProviderBase

2, implement a section, used to read from the configuration file provider related configuration, the class inherits from ConfigurationSection

3, in the call to read the configuration file, and load the specified provider

What do I think of the data storage section in BlogEngine.NET (personal point of view, not to mind)?

BlogEngine.NET can support a variety of data storage, in its current version we can see the XML (by default, mainly for the installation of Plug and Play considerations) and the database two ways of storage. The provider of the BlogEngine.NET data store is just about how the data is stored (without some logical processing and operation), so the requirements for the database are very low, as long as the SQL statement is supported and the data can be stored, in fact it has only a few tables in the database, from its provider implementation and Instead of using the database's primary key cascading deletions and so on, complete with multiple Embedded SQL statements, this allows BlogEngine.NET to support more databases. For the storage of the database BlogEngine.NET only use a dbblogprovider, and do not specifically distinguish what kind of database to use, we only in the configuration file according to the link string set ProviderName can specify the specific database storage. BlogEngine.NET's approach to data processing is not highly recommended in a system with complex business logic.

Then let's take a look at how the ProviderBase is used in blogengine.net to complete the data storage problem.

Look at an inheritance diagram first:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.