Skip to content

vertizens/SliceR.Samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SliceR.Samples

Samples for usage of SliceR.

Contoso University API

Sample of a mostly convention based API for CRUD with some customization for Domain models.

Build your own API

Quick steps of creating an API

Use Extensions

  • Vertizens.SliceR.Minimal
  • Vertizens.SliceR.Operations.EntityFrameworkCore
  • Vertizens.SliceR.Validated.Fluent

App builder (Program.cs)

  • call to register services
  • app.AddEndpointBuilders();

Services

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

DbContext Entities

Stick with conventions

  • int Id as key
  • Related entities as properties with ForeignKey property {RelatedEntityName}Id
    • ICollection<RelatedEntity> or RelatedEntity as type

AbstractValidator<TRequestIn>

If using Fluent Validation and need validation

IEndpointBuilder

  • MapEntityRouteGroup - entity route builder if routes map to entity operations
  • Map<Verb>As... - map endpoints

ITypeMapperBuilder<TRequestIn, TEntity>

  • 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

ITypeProjector<TEntity, ResponseDto>

  • 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

About

Samples collections for SliceR and its extensions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages