|
DataSmith 0.1.2
|
DataSmith supports external databases through a pluggable provider system.
Instead of hardcoding a specific database engine, DataSmith communicates with databases through the IDatabase interface. This allows you to switch between storage backends without changing your model code.
Database-backed models use ModelValueType.DB.
These models:
๐๏ธ Enabling Database Models
Mark your model with ModelValueType.DB.
Generated models will use the active database provider for storage and queries.
DataSmith communicates with databases using the IDatabase interface.
A provider implements this interface and executes commands against a specific backend.
Example Interface
The exact interface may vary depending on the provider implementation.
The active database provider is configured through the DataContext.
Once configured, all DB models will use this provider automatically.
DataSmith can work with Mono.Data.Sqlite when available.
SQLite is ideal for:
Requirements
You can implement support for any database system by creating your own provider.
Example: Custom Provider
Then register it:
DataContext.Database = new MyDatabase();
๐ Database Queries
For DB models, generated queries may be translated into database commands instead of in-memory filtering.
Example usage:
The provider determines how this query is executed.
๐พ Persistence Behavior
Unlike in-memory models: