Skip to content

Commit c7f3642

Browse files
Update documentation to replace int with long
1 parent 36f38d5 commit c7f3642

File tree

9 files changed

+32
-32
lines changed

9 files changed

+32
-32
lines changed

docs/usage/errors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ This handler is also the place to choose the log level and message, based on the
3434
```c#
3535
public class ProductOutOfStockException : Exception
3636
{
37-
public int ProductId { get; }
37+
public long ProductId { get; }
3838

39-
public ProductOutOfStockException(int productId)
39+
public ProductOutOfStockException(long productId)
4040
{
4141
ProductId = productId;
4242
}

docs/usage/extensibility/controllers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ You can even make your own mix of allowed routes by calling the alternate constr
126126
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 `IResourceService` implementation, so simply inject the implementation that is available.
127127

128128
```c#
129-
public class ReportsController : JsonApiController<Report, int>
129+
public class ReportsController : JsonApiController<Report, long>
130130
{
131131
public ReportsController(IJsonApiOptions options, IResourceGraph resourceGraph,
132-
ILoggerFactory loggerFactory, IGetAllService<Report, int> getAllService)
132+
ILoggerFactory loggerFactory, IGetAllService<Report, long> getAllService)
133133
: base(options, resourceGraph, loggerFactory, getAll: getAllService)
134134
{
135135
}

docs/usage/extensibility/repositories.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ If you only need minor changes you can override the methods defined in `EntityFr
55

66
```c#
77
// Program.cs
8-
builder.Services.AddScoped<IResourceRepository<Article, int>, ArticleRepository>();
9-
builder.Services.AddScoped<IResourceReadRepository<Article, int>, ArticleRepository>();
10-
builder.Services.AddScoped<IResourceWriteRepository<Article, int>, ArticleRepository>();
8+
builder.Services.AddScoped<IResourceRepository<Article, long>, ArticleRepository>();
9+
builder.Services.AddScoped<IResourceReadRepository<Article, long>, ArticleRepository>();
10+
builder.Services.AddScoped<IResourceWriteRepository<Article, long>, ArticleRepository>();
1111
```
1212

1313
In v4.0 we introduced an extension method that you can use to register a resource repository on all of its JsonApiDotNetCore interfaces.
@@ -26,7 +26,7 @@ A sample implementation that performs authorization might look like this.
2626
All of the methods in EntityFrameworkCoreRepository will use the `GetAll()` method to get the `DbSet<TResource>`, so this is a good method to apply filters such as user or tenant authorization.
2727

2828
```c#
29-
public class ArticleRepository : EntityFrameworkCoreRepository<Article, int>
29+
public class ArticleRepository : EntityFrameworkCoreRepository<Article, long>
3030
{
3131
private readonly IAuthenticationService _authenticationService;
3232

docs/usage/extensibility/resource-definitions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ builder.Services.AddResourceDefinition<ArticleDefinition>();
1818
> [!NOTE]
1919
> Prior to the introduction of auto-discovery (in v3), you needed to register the resource definition on the container yourself:
2020
> ```c#
21-
> builder.Services.AddScoped<ResourceDefinition<Article, int>, ArticleDefinition>();
21+
> builder.Services.AddScoped<ResourceDefinition<Article, long>, ArticleDefinition>();
2222
> ```
2323
2424
## Customizing queries
@@ -41,7 +41,7 @@ For example, you may accept some sensitive data that should only be exposed to a
4141
> To exclude fields unconditionally, [attribute capabilities](~/usage/resources/attributes.md#capabilities) and [relationship capabilities](~/usage/resources/relationships.md#capabilities) can be used instead.
4242
4343
```c#
44-
public class UserDefinition : JsonApiResourceDefinition<User, int>
44+
public class UserDefinition : JsonApiResourceDefinition<User, long>
4545
{
4646
public UserDefinition(IResourceGraph resourceGraph)
4747
: base(resourceGraph)
@@ -100,7 +100,7 @@ Content-Type: application/vnd.api+json
100100
You can define the default sort order if no `sort` query string parameter is provided.
101101

102102
```c#
103-
public class AccountDefinition : JsonApiResourceDefinition<Account, int>
103+
public class AccountDefinition : JsonApiResourceDefinition<Account, long>
104104
{
105105
public AccountDefinition(IResourceGraph resourceGraph)
106106
: base(resourceGraph)
@@ -128,7 +128,7 @@ public class AccountDefinition : JsonApiResourceDefinition<Account, int>
128128
You may want to enforce pagination on large database tables.
129129

130130
```c#
131-
public class AccessLogDefinition : JsonApiResourceDefinition<AccessLog, int>
131+
public class AccessLogDefinition : JsonApiResourceDefinition<AccessLog, long>
132132
{
133133
public AccessLogDefinition(IResourceGraph resourceGraph)
134134
: base(resourceGraph)
@@ -159,7 +159,7 @@ public class AccessLogDefinition : JsonApiResourceDefinition<AccessLog, int>
159159
The next example filters out `Account` resources that are suspended.
160160

161161
```c#
162-
public class AccountDefinition : JsonApiResourceDefinition<Account, int>
162+
public class AccountDefinition : JsonApiResourceDefinition<Account, long>
163163
{
164164
public AccountDefinition(IResourceGraph resourceGraph)
165165
: base(resourceGraph)
@@ -188,7 +188,7 @@ public class AccountDefinition : JsonApiResourceDefinition<Account, int>
188188
In the example below, an error is returned when a user tries to include the manager of an employee.
189189

190190
```c#
191-
public class EmployeeDefinition : JsonApiResourceDefinition<Employee, int>
191+
public class EmployeeDefinition : JsonApiResourceDefinition<Employee, long>
192192
{
193193
public EmployeeDefinition(IResourceGraph resourceGraph)
194194
: base(resourceGraph)
@@ -224,7 +224,7 @@ If the key is present in a query string, the supplied LINQ expression will be ad
224224
But it only works on primary resource endpoints (for example: /articles, but not on /blogs/1/articles or /blogs?include=articles).
225225

226226
```c#
227-
public class ItemDefinition : JsonApiResourceDefinition<Item, int>
227+
public class ItemDefinition : JsonApiResourceDefinition<Item, long>
228228
{
229229
public ItemDefinition(IResourceGraph resourceGraph)
230230
: base(resourceGraph)

docs/usage/extensibility/services.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In simple cases, you can also just wrap the base implementation with your custom
1212
A simple example would be to send notifications when a resource gets created.
1313

1414
```c#
15-
public class TodoItemService : JsonApiResourceService<TodoItem, int>
15+
public class TodoItemService : JsonApiResourceService<TodoItem, long>
1616
{
1717
private readonly INotificationService _notificationService;
1818

@@ -51,14 +51,14 @@ If you'd like to use another ORM that does not provide what JsonApiResourceServi
5151
// Program.cs
5252
5353
// Add the service override for Product.
54-
builder.Services.AddScoped<IResourceService<Product, int>, ProductService>();
54+
builder.Services.AddScoped<IResourceService<Product, long>, ProductService>();
5555

5656
// Add your own Data Access Object.
5757
builder.Services.AddScoped<IProductDao, ProductDao>();
5858

5959
// ProductService.cs
6060
61-
public class ProductService : IResourceService<Product, int>
61+
public class ProductService : IResourceService<Product, long>
6262
{
6363
private readonly IProductDao _dao;
6464

@@ -114,14 +114,14 @@ IResourceCommandService <|-- IRemoveFromRelationshipService
114114
In order to take advantage of these interfaces you first need to register the service for each implemented interface.
115115

116116
```c#
117-
public class ArticleService : ICreateService<Article, int>, IDeleteService<Article, int>
117+
public class ArticleService : ICreateService<Article, long>, IDeleteService<Article, long>
118118
{
119119
// ...
120120
}
121121

122122
// Program.cs
123-
builder.Services.AddScoped<ICreateService<Article, int>, ArticleService>();
124-
builder.Services.AddScoped<IDeleteService<Article, int>, ArticleService>();
123+
builder.Services.AddScoped<ICreateService<Article, long>, ArticleService>();
124+
builder.Services.AddScoped<IDeleteService<Article, long>, ArticleService>();
125125
```
126126

127127
In v3.0 we introduced an extension method that you can use to register a resource service on all of its JsonApiDotNetCore interfaces.
@@ -149,11 +149,11 @@ public class Article : identifiable<long>
149149
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:
150150

151151
```c#
152-
public class ArticlesController : JsonApiController<Article, int>
152+
public class ArticlesController : JsonApiController<Article, long>
153153
{
154154
public ArticlesController(IJsonApiOptions options, IResourceGraph resourceGraph,
155-
ILoggerFactory loggerFactory, ICreateService<Article, int> create,
156-
IDeleteService<Article, int> delete)
155+
ILoggerFactory loggerFactory, ICreateService<Article, long> create,
156+
IDeleteService<Article, long> delete)
157157
: base(options, resourceGraph, loggerFactory, create: create, delete: delete)
158158
{
159159
}

docs/usage/meta.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Resource-specific metadata can be added by implementing `IResourceDefinition<TRe
4747
```c#
4848
#nullable enable
4949

50-
public class PersonDefinition : JsonApiResourceDefinition<Person, int>
50+
public class PersonDefinition : JsonApiResourceDefinition<Person, long>
5151
{
5252
public PersonDefinition(IResourceGraph resourceGraph)
5353
: base(resourceGraph)

docs/usage/resource-graph.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ You can manually construct the graph.
5454
```c#
5555
// Program.cs
5656
builder.Services.AddJsonApi(resources: resourceGraphBuilder =>
57-
resourceGraphBuilder.Add<Person, int>());
57+
resourceGraphBuilder.Add<Person, long>());
5858
```
5959

6060
## Resource Name
@@ -66,7 +66,7 @@ The public resource name is exposed through the `type` member in the JSON:API pa
6666
// Program.cs
6767
builder.Services.AddJsonApi(resources: resourceGraphBuilder =>
6868
{
69-
resourceGraphBuilder.Add<Person, int>(publicName: "individuals");
69+
resourceGraphBuilder.Add<Person, long>(publicName: "individuals");
7070
});
7171
```
7272

docs/usage/resources/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Person : identifiable<long>
1818
{
1919
[Key]
2020
[Column("PersonID")]
21-
public override int Id { get; set; }
21+
public override long Id { get; set; }
2222
}
2323
```
2424

docs/usage/routing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public class OrderSummary : identifiable<long>
2828
}
2929

3030
// Hand-written
31-
public class OrderLineController : JsonApiController<OrderLine, int>
31+
public class OrderLineController : JsonApiController<OrderLine, long>
3232
{
3333
public OrderLineController(IJsonApiOptions options, IResourceGraph resourceGraph,
34-
ILoggerFactory loggerFactory, IResourceService<OrderLine, int> resourceService)
34+
ILoggerFactory loggerFactory, IResourceService<OrderLine, long> resourceService)
3535
: base(options, resourceGraph, loggerFactory, resourceService)
3636
{
3737
}
@@ -74,10 +74,10 @@ partial class OrderSummariesController
7474
// Hand-written
7575
[DisableRoutingConvention]
7676
[Route("custom/route/lines-in-order")]
77-
public class OrderLineController : JsonApiController<OrderLine, int>
77+
public class OrderLineController : JsonApiController<OrderLine, long>
7878
{
7979
public OrderLineController(IJsonApiOptions options, IResourceGraph resourceGraph,
80-
ILoggerFactory loggerFactory, IResourceService<OrderLine, int> resourceService)
80+
ILoggerFactory loggerFactory, IResourceService<OrderLine, long> resourceService)
8181
: base(options, resourceGraph, loggerFactory, resourceService)
8282
{
8383
}

0 commit comments

Comments
 (0)