You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Likewise, to provide write-only access, inherit from <code>JsonApiCommandController</code>, which blocks all GET and HEAD requests.</p>
184
184
<p>You can even make your own mix of allowed routes by calling the alternate constructor of <code>JsonApiController</code> and injecting the set of service implementations available.
185
185
In some cases, resources may be an aggregation of entities or a view on top of the underlying entities. In these cases, there may not be a writable <code>IResourceService</code> implementation, so simply inject the implementation that is available.</p>
186
-
<pre><codeclass="lang-c#">public class ReportsController : JsonApiController<Report, int>
186
+
<pre><codeclass="lang-c#">public class ReportsController : JsonApiController<Report, long>
187
187
{
188
188
public ReportsController(IJsonApiOptions options, IResourceGraph resourceGraph,
<p>If you want to use a data access technology other than Entity Framework Core, you can create an implementation of <code>IResourceRepository<TResource, TId></code>.
94
94
If you only need minor changes you can override the methods defined in <code>EntityFrameworkCoreRepository<TResource, TId></code>.</p>
<p>In v4.0 we introduced an extension method that you can use to register a resource repository on all of its JsonApiDotNetCore interfaces.
101
101
This is helpful when you implement (a subset of) the resource interfaces and want to register them all in one go.</p>
@@ -108,7 +108,7 @@ <h5>Tip</h5>
108
108
</div>
109
109
<p>A sample implementation that performs authorization might look like this.</p>
110
110
<p>All of the methods in EntityFrameworkCoreRepository will use the <code>GetAll()</code> method to get the <code>DbSet<TResource></code>, so this is a good method to apply filters such as user or tenant authorization.</p>
111
-
<pre><codeclass="lang-c#">public class ArticleRepository : EntityFrameworkCoreRepository<Article, int>
111
+
<pre><codeclass="lang-c#">public class ArticleRepository : EntityFrameworkCoreRepository<Article, long>
<p>To exclude fields unconditionally, <ahref="../resources/attributes.html#capabilities">attribute capabilities</a> and <ahref="../resources/relationships.html#capabilities">relationship capabilities</a> can be used instead.</p>
123
123
</div>
124
-
<pre><codeclass="lang-c#">public class UserDefinition : JsonApiResourceDefinition<User, int>
124
+
<pre><codeclass="lang-c#">public class UserDefinition : JsonApiResourceDefinition<User, long>
125
125
{
126
126
public UserDefinition(IResourceGraph resourceGraph)
<h3id="block-including-related-resources">Block including related resources</h3>
249
249
<p>In the example below, an error is returned when a user tries to include the manager of an employee.</p>
250
-
<pre><codeclass="lang-c#">public class EmployeeDefinition : JsonApiResourceDefinition<Employee, int>
250
+
<pre><codeclass="lang-c#">public class EmployeeDefinition : JsonApiResourceDefinition<Employee, long>
251
251
{
252
252
public EmployeeDefinition(IResourceGraph resourceGraph)
253
253
: base(resourceGraph)
@@ -279,7 +279,7 @@ <h5>Note</h5>
279
279
<p>This directly influences the Entity Framework Core <code>IQueryable</code>. As opposed to using <code>OnApplyFilter</code>, this enables the full range of Entity Framework Core operators.
280
280
But it only works on primary resource endpoints (for example: /articles, but not on /blogs/1/articles or /blogs?include=articles).</p>
281
281
</div>
282
-
<pre><codeclass="lang-c#">public class ItemDefinition : JsonApiResourceDefinition<Item, int>
282
+
<pre><codeclass="lang-c#">public class ItemDefinition : JsonApiResourceDefinition<Item, long>
283
283
{
284
284
public ItemDefinition(IResourceGraph resourceGraph)
<p>If you don't need to alter the underlying mechanisms, you can inherit from <code>JsonApiResourceService<TResource, TId></code> and override the existing methods.
98
98
In simple cases, you can also just wrap the base implementation with your custom logic.</p>
99
99
<p>A simple example would be to send notifications when a resource gets created.</p>
100
-
<pre><codeclass="lang-c#">public class TodoItemService : JsonApiResourceService<TodoItem, int>
100
+
<pre><codeclass="lang-c#">public class TodoItemService : JsonApiResourceService<TodoItem, long>
<p>Alternatively, when using a hand-written controller, you should inherit from the JSON:API controller and pass the services into the named, optional base parameters:</p>
217
-
<pre><codeclass="lang-c#">public class ArticlesController : JsonApiController<Article, int>
217
+
<pre><codeclass="lang-c#">public class ArticlesController : JsonApiController<Article, long>
218
218
{
219
219
public ArticlesController(IJsonApiOptions options, IResourceGraph resourceGraph,
<p>Resource-specific metadata can be added by implementing <code>IResourceDefinition<TResource, TId>.GetMeta</code> (or overriding it on <code>JsonApiResourceDefinition<TResource, TId></code>):</p>
128
128
<pre><codeclass="lang-c#">#nullable enable
129
129
130
-
public class PersonDefinition : JsonApiResourceDefinition<Person, int>
130
+
public class PersonDefinition : JsonApiResourceDefinition<Person, long>
131
131
{
132
132
public PersonDefinition(IResourceGraph resourceGraph)
<p>The public resource name is exposed through the <code>type</code> member in the JSON:API payload. This can be configured using the following approaches (in order of priority):</p>
0 commit comments