Add basic documentation and usage examples#22
Conversation
| } | ||
|
|
||
| // 3. Define an entity and query it | ||
| public class IdentityQueryFilter { public string Name { get; set; } } |
There was a problem hiding this comment.
For a quick start IdentityFilter class is not neccessary. Assuming that the user will only filter on the actual entity columns then the Identity class with "virtual" properties can be used and the entity will do the filter mapping automatically.
The separate "filter" class and mapping is only necessary if we are changing/expanding the filtering beyond the basic columns.
- Use the model itself as the filter type in quick-start examples (virtual properties are auto-mapped by the base Entity.Filter), removing the unnecessary separate filter class from README and USAGE quick-start sections. - Keep the custom TFilter + Filter override example in USAGE.md but reframe it as an advanced scenario for when filtering needs to be customised beyond basic column mapping. - Rewrite the 'Core concepts' bullets in USAGE.md to describe the actual design goals (datasource-agnostic, type-safe, free implementation details) instead of implementation specifics.
|
Addressed the review feedback in 7195dad:
|
| // A separate filter class isn't necessary for a quick start – the base Entity.Filter | ||
| // maps "virtual" model properties automatically, so the model itself can be used as | ||
| // the filter type. | ||
| public class IdentityEntity : Entity<Identity, DbQueryOptions> |
There was a problem hiding this comment.
Declaring an entity is not neccessary, the simplest version is
var entity = new Entity(repository, new Table("I"));
Why would one want to declare the IdentityEntity? To avoid using complicated type names such as Entity<Identity, IdentityFilter, DbQueryOptions> all over the place when things get extended. The more complicated version should be noted in the usage.md with the reasons.
We need a task to further simplify this to Entity(repository, string tableName), as well.
Per review feedback, the quick-start example doesn't need a custom IdentityEntity subclass. Entity<T> can be instantiated directly with a Table<T>, since a dedicated subclass is only useful once type names get long or behaviour needs extending. README now uses Entity<Identity> directly, and USAGE.md's 'Defining an Entity' section leads with the minimal Entity<T> form before introducing the IdentityEntity convenience class.
|
Addressed the remaining review feedback in 1d8fe44:
|
Summary
Adds a README overview/quick-start plus a full
docs/USAGE.mdguide covering:TypeMetaconfiguration and how it's resolved viaTable<T>SqlRepository,DbRepository)Entity<TModel, TFilter, TOptions>with custom filteringListAsync(including filters, projections, and tuple joins),GetAsync/ExistsAsync, and Add/Update/Upsert/DeleteTest plan
TypeMeta,Table<T>,Entity<TModel, TFilter, TOptions>,DbRepository,SqlRepository,ListAsyncoverloads, etc.) exist in the current codebase by reading the relevant source and test files (e.g.Meta/TypeMeta.cs,Table.cs,DbRepository.cs,Entity/Entity.cs,Db.Test/SqlServer/Entity/EntityTest.cs).Risks / things to double check
Closes #21