|
DataSmith 0.1.2
|
DataSmith provides a strongly-typed, fluent query system for retrieving data from models.
Queries are generated automatically for each model and allow you to filter data using a readable builder pattern.
Queries operate on model data without modifying it.
Key characteristics:
For every model, DataSmith generates a corresponding query class:
Example
These classes are auto-generated and should not be edited manually.
Queries are created from a model instance.
Query methods correspond to the public fields of the model.
Multiple conditions can be chained:
DataSmith generates methods based on field types.
For numeric fields:
For string fields:
If a field references another model via the Reference attribute, DataSmith generates helper methods that accept the referenced object.
Internally this compares primary keys.
You can supply your own predicate using Where.
Queries are evaluated only when enumerated.
Calling Execute() returns an enumerable result.
Queries can also be used directly in LINQ:
Behavior depends on the generated model type.
For database models (ModelValueType.DB), queries may be translated into SQL and executed by the configured database provider.
Exact behavior depends on the active IDatabase implementation.
✔ Prefer generated methods over manual predicates
✔ Chain conditions for clarity
✔ Avoid expensive logic inside Where
✔ Treat queries as read-only operations