Samples for usage of SliceR.
Sample of a mostly convention based API for CRUD with some customization for Domain models.
Quick steps of creating an API
- Vertizens.SliceR.Minimal
- Vertizens.SliceR.Operations.EntityFrameworkCore
- Vertizens.SliceR.Validated.Fluent
- call to register services
- app.AddEndpointBuilders();
Register in dependency order
services.AddDbContext...
services.AddTypeMappers(); //TypeMapper
services.AddSliceRHandlers(); //SliceR
services.AddSliceRValidatedHandlers(); //SliceR
services.AddSliceREndpointBuilders(); //SliceR.Minimal
services.AddSliceREntityFrameworkCoreDefaultHandlers(); //SliceR.Operations.EntityFrameworkCore
services.AddSliceREndpointDefaultValidatedHandlers(); //SliceR.Minimal
services.AddSliceRFluentValidators() //SliceR.Validated.Fluent
Stick with conventions
- int Id as key
- Related entities as properties with ForeignKey property {RelatedEntityName}Id
- ICollection<RelatedEntity> or RelatedEntity as type
If using Fluent Validation and need validation
- MapEntityRouteGroup - entity route builder if routes map to entity operations
- Map<Verb>As... - map endpoints
- Create an implementation if the Insert or Update domain is a different graph than TEntity
- ApplyNameMatch() should be called to match name/type by default
- Create an implementation if a query domain is a different graph than TEntity
- ApplyNameMatch() should be called to match name/type by default then Union with custom