YetaWF stores most data in table format. Data tables can be located in files, SQL DBs, RavenDB documents, or many other data repositories. Applications always access data through an application data provider.
An application data provider is the high-level API used by an application to access data in table format. An example of an application data provider is the class YetaWF.Modules.Blog.DataProvider.BlogCategoryDataProvider, which provides access to blog categories and supports browse, read, update and remove methods.
The following example shows how an application data provider is obtained by an application and used to add one record.
using (BlogCategoryDataProvider dataProvider = new BlogCategoryDataProvider()) { if (!await dataProvider.AddItemAsync(model.GetData())) { ModelState.AddModelError(nameof(model.Name), this.__ResStr("alreadyExists", "A blog category named \"0\" already exists.", model.Category)); return PartialView(model); } return FormProcessed(model, this.__ResStr("okSaved", "New blog category saved"), OnPopupClose: OnPopupCloseEnum.ReloadModule); }
Application data providers can be configured using AppSettings.json. Each data provider supports its own set of properties, which should be documented in each application data provider. The AppSettings.json settings determine where the data is stored and which low-level data provider is used.
An application data provider (like BlogCategoryDataProvider above) doesn't directly perform I/O. While the application data provider determines the data location and format, it defers to a low-level data provider to read/write all data. YetaWF includes low-level data providers for SQL DBs and File I/O. Low-level data providers for other data repositories (like RavenDB) were created, they are not part of the open source project.
Low-Level Data Provider | Description |
---|---|
File | Implements record-based I/O using the file system. |
SQL | Implements record-based I/O using SQL databases using stored procedures. |
SQLDyn | Implements record-based I/O using SQL databases using dynamic SQL. |
PostgreSQL | Implements record-based I/O using PostgreSQL databases. |
Low-level data providers all offer the same basic support as they implement the following interfaces:
Interface | Description |
---|---|
YetaWF.Core.DataProvider.IDataProvider<KEYTYPE,OBJTYPE> | This interface is implemented by low-level data providers that offer access to record-based data with one primary key, without record identity. |
YetaWF.Core.DataProvider.IDataProviderIdentity<KEYTYPE,KEY2TYPE,OBJTYPE> | This interface is implemented by low-level data providers that offer access to record-based data with up to two primary keys and a record identity. |
YetaWF.Core.DataProvider.IDataProviderTransactions | This interface is implemented by low-level data providers to support transactions that can be committed, saving all updates, or aborted to abandon all updates. While always implemented by all low-level data providers, support for transactions may not be available. |
System.IDisposable | Provides a mechanism for releasing unmanaged resources. |
A low-level data provider may take advantage of the available core data providers and local/shared caching provided by YetaWF.
YetaWF provides some basic "core" data providers, which may be used by low-level data providers and data providers in general.
Core Data Provider | Description |
---|---|
YetaWF.Core.IO.Caching | Implements local, shared and static caching. |
YetaWF.Core.IO.DataFilesProvider | Implements data files and supports retrieval of folders with data files. |
YetaWF.Core.IO.FileIO<TObj> | Implements file I/O for one object of type TObj. |
YetaWF.Core.IO.FileSystem | Implements filesystem access to a permanent and a temporary repository. |
YetaWF.Core.IO.SessionStateIO<TObj> | Implements .NET session state I/O for an object of type TObj. |
YetaWF provides a module data provider that implements a module repository, where all module data is stored.
Module Data Provider | Description |
---|---|
YetaWF.DataProvider.ModuleDefinition Package | The package supports file I/O and SQL tables for module data. |
A module data provider is a special type of data provider. It installs itself during application startup by providing access methods in the static class YetaWF.Core.IO.Module. The access methods provided in YetaWF.Core.IO.Module are for framework use only.
The module data provider can be configured using AppSettings.json. It uses the IOMode setting in the YetaWF_Core section. If none is specified, the Default section is used.
Possible IOMode settings are File, SQL or PostgreSQL. If SQL is specified, the SQLDbo and SQLConnect properties must be provided. If PostgreSQL is specified, the PostgreSQLSchema and PostgreSQLConnect properties must be provided.
{ "Application": { "P": { "Default": { "IOMode": "File", }, "YetaWF_Core": { "IOMode": "File" }, }, }, }
{ "Application": { "P": { "Default": { "IOMode": "SQL", "SQLDbo": "dbo", "SQLConnect": "Data Source=..datasource..;Initial Catalog=..catalog..;User ID=..userid..;Password=..password.." }, "YetaWF_Core": { "IOMode": "SQL", "SQLDbo": "dbo", "SQLConnect": "Data Source=..datasource..;Initial Catalog=..catalog..;User ID=..userid..;Password=..password.." }, }, }, }
{ "Application": { "P": { "Default": { "IOMode": "PostgreSQL", "PostgreSQLSchema": "public", "PostgreSQLConnect": "Host=..host..;Port=..port..;Username=..user..;Password=..password..;Database=..database.." }, "YetaWF_Core": { "IOMode": "PostgreSQL", "PostgreSQLSchema": "public", "PostgreSQLConnect": "Host=..host..;Port=..port..;Username=..user..;Password=..password..;Database=..database.." }, }, }, }
The module data provider is currently somewhat tightly integrated into YetaWF as modules use a template class in the module data provider to implement their own data provider. This may change at some time to make the module data provider completely replaceable (plug and play) like other low-level components in YetaWF.
YetaWF provides a localization data provider that implements loading/saving localization resources.
Localization Data Provider | Description |
---|---|
YetaWF.DataProvider.Localization Package | The package supports loading/saving localization resources. |
A localization data provider is a special type of data provider. It installs itself during application startup by providing access methods in the static class YetaWF.Core.IO.Localization. The access methods provided in YetaWF.Core.IO.Localization are for framework use only.
Last Updated 12/12/2020 - (email)
© 2023 - Softel vdm, Inc. - YetaWF.com