Data Models
A data model must be a C# class with a public parameterless constructor. LiteDB.Get<T>() and LiteDB.Query<T>() match the result column names to the model's public settable properties or public fields.
IDataBase
GetList, Exist, and TryGetValue rely on IDataBase, expecting Id and Name.
Supported attributes
[AutoIncrement] and [NotNull] are not used during runtime schema generation because the package does not provide a table-creation API. They exist to keep the meaning consistent when creating a schema with the CSV Importer or an external DB tool.
Column mapping
Mapping is case-insensitive by default.
Properties without a setter and readonly fields are excluded from mapping.
Type mapping
The query API operates on the Id column. SQLite types map to C# types as follows.
Recommended rules:
- Give the table an
Idcolumn. - Manage
Idas the primary key for models you look up by a single key. - Keep C# property names the same as DB column names.
- Use
[Table("TableName")]when the class name and table name differ.