Skip to content

Commit

Permalink
minor documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
gpproton committed Jan 13, 2024
1 parent 911b0e6 commit 5adbdf5
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

A personal shared library for various types of dotnet project types

NOTE: Issues can be created to improve documentation and fix errors

### Sub-packages

Expand All @@ -13,8 +14,6 @@ Axolotl.EFCore:

Axolotl.Razor:

Axolotl.Maui:


# Install

Expand All @@ -34,7 +33,6 @@ Install-Package Axolotl.Http
Install-Package Axolotl.EFCore
Install-Package Axolotl.AspNet
Install-Package Axolotl.Razor
Install-Package Axolotl.Maui
```

## Asp.Net Core Samples
Expand Down Expand Up @@ -69,10 +67,27 @@ public class ServiceContext : DbContext {
}
```

### Create your generic repository and apply DbContext

```csharp
public class GenericRepository<TEntity, TKey> : GenericBaseRepository<TEntity, ServiceContext, TKey>
where TEntity : class, IAggregateRoot, IHasKey<TKey>
where TKey : notnull {
public GenericRepository(ServiceContext context) : base(context) { }
}
```

### Register generic repository

```csharp
builder.Services.RegisterGenericRepositories(typeof(GenericRepository<,>));
builder.Services.RegisterGenericServices();
```

### Create optional filter specification

```csharp
public sealed class CategorySpec : Specification<Post> {
public sealed class CategorySpec : Specification<Post, Guid> {
public CategorySpec(IPageFilter filter) {
var search = filter.Search ?? string.Empty;
var text = search.ToLower().Split(" ").ToList().Select(x => x);
Expand All @@ -86,7 +101,7 @@ public sealed class CategorySpec : Specification<Post> {
### Create feature/endpoint

```csharp
public class CategoryFeature : GenericFeature<CategoryFeature> {
public class CategoryFeature : GenericFeature<CategoryFeature, Guid> {
public override IEndpointRouteBuilder MapEndpoints(IEndpointRouteBuilder endpoints) {
var state = new FeatureState(new List<RouteState> {
new (RouteType.GetAll, typeof(CategorySpec)),
Expand Down

0 comments on commit 5adbdf5

Please sign in to comment.