In the past, when developing Winform gadgets, configuration files were often stored in text as json strings, which was suitable for simple data storage. SQL Server and MySQL are too heavy, and you need to build an environment on the computer, SQLite, is a lightweight database, is an ACID-compliant relational database management system, it is contained in a relatively small C library.
In simple terms, SQLite is a database file that supports multiple languages and cross-platforms. It can be used on Windows, Linux, mobile (Android), and other platforms.
Review:
Create a new .NET Core 3.1 project (Code can be migrated directly to the .NET framework)
Download two .cs files from the GitHub repository,The two .cs files are a complete SQLite ORM frameworkAddress:The hyperlink login is visible.
copySQLite.cs、SQLiteAsync.csfile into the project (if you don't use asynchronous SQLiteAsync.cs, you can do without copying), as shown in the image below:
Download the SQLite binary at the following address:The hyperlink login is visible.
I download "SQLite version 3.37.0 32-bit DLL (x86)" here, address:The hyperlink login is visible., unzip the package, copy sqlite3.dll into the project,Copy the setup file if it is newer。
Create a new UserInfo table, simply add, delete, modify the table, and check the code:
Since I'm using a 32-bit DLL, put the projectThe target platform is changed to x86, as shown in the figure below:
Run the program, and the execution result is as shown in the figure below:
Source code download:
The hyperlink login is visible.
|