What does the provider class mean in the .NET world?

There are many classes that have this provider suffix. (Data, membership, modelmetadata, ...).

When should there be a class called a provider class?

+4
source share
2 answers

Providers are mostly between your logic and any type of data warehouse (database, xml, etc.). MSDN mentions:

Providers of abstract storage media are much the same as device drivers abstract hardware devices.

For More Information: Microsoft ASP.NET 2.0 Providers: Introduction

For example: Instead of working with a database or XML, you want to work with file storage on disk somewhere in your network. To manage this, you create a custom provider and use it in your logic to save data.

+4
source

Here is a description of the provider template from MS (http://msdn.microsoft.com/en-us/library/ms972319.aspx):

The template itself is extremely simple and given the name "provider" because it provides functionality for the API. Defined, the provider is just a contract between the API and the business logic / data abstraction layer. A provider is an implementation of a separate API from the API itself. For example, the new Whidbey Membership function has a static method called Membership.ValidateUser (). The membership class itself does not contain business logic; instead, it simply redirects this call to the configured provider. Responsibility for the provider class that contains implementations for this method, a call to any business logic level (BLL), or data access level (DAL) is necessary.

There are some rules for how a supplier behaves. Supplier implementation should be based on an abstract base class that is used to define a contract for a particular feature. For example, to create a membership provider for Oracle, you create a new OracleMembershipProvider class that derives from MemberhipProviderBase. The base class of the function, for example, MembershipProviderBase, in turn, comes from the common provider base class. Class ProviderBase - this is used to designate executors as a provider and forces the required method and properties common to all providers. Figure 4 gives an example of chain inheritance.

+4
source

Source: https://habr.com/ru/post/1304552/


All Articles