Skip to content

Commit 75ae1b5

Browse files
committed
docs(readme): show ResourceAttribute usage
1 parent b0146c4 commit 75ae1b5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ JsonApiDotnetCore provides a framework for building [json:api](http://jsonapi.or
1717
- [Defining Models](#defining-models)
1818
- [Specifying Public Attributes](#specifying-public-attributes)
1919
- [Relationships](#relationships)
20+
- [Resource Names](#resource-names)
2021
- [Defining Controllers](#defining-controllers)
2122
- [Non-Integer Type Keys](#non-integer-type-keys)
2223
- [Routing](#routing)
@@ -169,6 +170,23 @@ public class TodoItem : Identifiable<int>
169170
}
170171
```
171172

173+
#### Resource Names
174+
175+
If a DbContext is specified when adding the services, the context will be used to define the resources and their names.
176+
177+
```csharp
178+
public DbSet<MyModel> SomeModels { get; set; } // this will be translated into "some-models"
179+
```
180+
181+
However, you can specify a custom name like so:
182+
183+
```csharp
184+
[Resource("some-models")]
185+
public DbSet<MyModel> MyModels { get; set; } // this will be translated into "some-models"
186+
```
187+
188+
For further resource customizations, please see the section on [Defining Custom Data Access Methods](#defining-custom-data-access-methods).
189+
172190
### Defining Controllers
173191

174192
You need to create controllers that inherit from `JsonApiController<TEntity>` or `JsonApiController<TEntity, TId>`

0 commit comments

Comments
 (0)