|
DataSmith 0.1.2
|
DataSmith uses a code-first model system.
You define plain C# classes, and DataSmith generates runtime model containers, queries, and persistence logic.
A model describes a type of data stored and managed by DataSmith.
Models are:
DataSmith generates companion classes that provide:
Mark a class with the GameModel attribute.
Run the generator to create the runtime model classes.
The ModelValueType determines how data is stored.
Stores exactly one instance of the data type.
Generated model:
Stores multiple items of the data type.
Generated model:
Uses an external database provider instead of in-memory storage.
Behavior depends on the configured database provider.
Attributes modify how models behave.
Marks a field as the unique identifier for the model.
For list models:
Indicates that a field refers to another model.
Typically stores the target modelβs primary key.
Generated code provides helper methods to retrieve the referenced object.
For each model type, DataSmith generates:
Example:
These classes handle runtime behavior and should not be edited manually.
Models are retrieved through the DataContext.
β Use simple public fields β Always define a primary key for list models β Avoid heavy logic inside model classes β Treat models as data containers only