Main | Add | Update |
---|---|---|
![]() |
![]() |
![]() |
An empty template that includes the forms above can be downloaded here. A full running example can be downloaded here.
The standard example program uses a list as data store. It can not be adaptet like the following program with abstraction. It can be found in the LibraryManagement
solution under _FormsNoAbstraction.
The example program with abstraction includes a modular IDataAccess
which is implemented by different libraries as BookDataAccess
with:
Book List
SQLite Database
EF Core
File
The abstract ValidateBookDataAccess
library implements the Validation of the Book
objects. It can be found in the LibraryManagement
solution under LibraryManagement.Access.
Implements a simple list in backend and is designed for testing purpose.
_bookDataAccess = new Access.Memory.BookDataAccess();
Data is saved in a SQLite database either with EFCore or with raw SQL. Can be used within every database that inherits from DbConnection
and DbCommand
(e.g. mSQL
, MySQL
, mariaDB
, ...
).
IConfiguration config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
// -> With native SQL (sqlite, mariadb, mysql, msql)
_connection = new SqliteConnection(config.GetConnectionString("SQLiteConnectionString"));
_bookDataAccess = new Access.Db.BookDataAccess(_connection);
// -> With EFCore
_connection = new SqliteConnection(config.GetConnectionString("SQLiteCoreConnectionString"));
DbContextOptionsBuilder builder = new DbContextOptionsBuilder<Access.Core.DataContext>()
.UseSqlite(_connection);
_bookDataAccess = new Access.Core.BookDataAccess(new Access.Core.DataContext(builder.Options));
Implements a file reader/writer for handling the list of books
_bookDataAccess = new Access.File.BookDataAccess("Books.dat");
R. GÄCHTER