Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

16 Commits

Repository files navigation

Version: 1.0 Release.NET Core DesktopcodecovLicense: GPL v3

C# library example

Program Layout

MainAddUpdate
FormMainFormDataFormData

An empty template that includes the forms above can be downloaded here. A full running example can be downloaded here.


Example program

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.


Example program with abstraction

The example program with abstraction includes a modular IDataAccess which is implemented by different libraries as BookDataAccess with:

  1. Book List
  2. SQLite Database
  3. EF Core
  4. File

The abstract ValidateBookDataAccess library implements the Validation of the Book objects. It can be found in the LibraryManagement solution under LibraryManagement.Access.

BookDataAccess as List

Implements a simple list in backend and is designed for testing purpose.

_bookDataAccess=newAccess.Memory.BookDataAccess();

BookDataAccess with Database

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, ...).

IConfigurationconfig=newConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();
// -> With native SQL (sqlite, mariadb, mysql, msql)_connection=newSqliteConnection(config.GetConnectionString("SQLiteConnectionString"));_bookDataAccess=newAccess.Db.BookDataAccess(_connection);
// -> With EFCore_connection=newSqliteConnection(config.GetConnectionString("SQLiteCoreConnectionString"));DbContextOptionsBuilderbuilder=newDbContextOptionsBuilder<Access.Core.DataContext>().UseSqlite(_connection);_bookDataAccess=newAccess.Core.BookDataAccess(newAccess.Core.DataContext(builder.Options));

BookDataAccess with File

Implements a file reader/writer for handling the list of books

_bookDataAccess=newAccess.File.BookDataAccess("Books.dat");

Global class diagram

Diagram


R. GÄCHTER

About

C# library example

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages