Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/Deserialization/DeserializationBenchmarkBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public abstract class DeserializationBenchmarkBase : IDisposable
protected DeserializationBenchmarkBase()
{
var options = new JsonApiOptions();
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<IncomingResource, int>().Build();
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<IncomingResource, long>().Build();
options.SerializerOptions.Converters.Add(new ResourceObjectConverter(resourceGraph));
SerializerReadOptions = ((IJsonApiOptions)options).SerializerReadOptions;

var resourceFactory = new ResourceFactory(_serviceProvider);
var resourceDefinitionAccessor = new ResourceDefinitionAccessor(resourceGraph, _serviceProvider);

_serviceProvider.AddService(typeof(IResourceDefinitionAccessor), resourceDefinitionAccessor);
_serviceProvider.AddService(typeof(IResourceDefinition<IncomingResource, int>), new JsonApiResourceDefinition<IncomingResource, int>(resourceGraph));
_serviceProvider.AddService(typeof(IResourceDefinition<IncomingResource, long>), new JsonApiResourceDefinition<IncomingResource, long>(resourceGraph));

// ReSharper disable once VirtualMemberCallInConstructor
JsonApiRequest request = CreateJsonApiRequest(resourceGraph);
Expand Down Expand Up @@ -71,7 +71,7 @@ private void Dispose(bool disposing)
}

[UsedImplicitly(ImplicitUseTargetFlags.Members)]
public sealed class IncomingResource : Identifiable<int>
public sealed class IncomingResource : Identifiable<long>
{
[Attr]
public bool Attribute01 { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/QueryString/QueryStringParserBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public QueryStringParserBenchmarks()
EnableLegacyFilterNotation = true
};

IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<QueryableResource, int>("alt-resource-name").Build();
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<QueryableResource, long>("alt-resource-name").Build();

var request = new JsonApiRequest
{
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/QueryString/QueryableResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Benchmarks.QueryString;

[UsedImplicitly(ImplicitUseTargetFlags.Members)]
public sealed class QueryableResource : Identifiable<int>
public sealed class QueryableResource : Identifiable<long>
{
[Attr(PublicName = "alt-attr-name")]
public string? Name { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/Serialization/SerializationBenchmarkBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected SerializationBenchmarkBase()
}
};

ResourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<OutgoingResource, int>().Build();
ResourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<OutgoingResource, long>().Build();
SerializerWriteOptions = ((IJsonApiOptions)options).SerializerWriteOptions;

// ReSharper disable VirtualMemberCallInConstructor
Expand All @@ -55,7 +55,7 @@ protected SerializationBenchmarkBase()
protected abstract IEvaluatedIncludeCache CreateEvaluatedIncludeCache(IResourceGraph resourceGraph);

[UsedImplicitly(ImplicitUseTargetFlags.Members)]
public sealed class OutgoingResource : Identifiable<int>
public sealed class OutgoingResource : Identifiable<long>
{
[Attr]
public bool Attribute01 { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ This handler is also the place to choose the log level and message, based on the
```c#
public class ProductOutOfStockException : Exception
{
public int ProductId { get; }
public long ProductId { get; }

public ProductOutOfStockException(int productId)
public ProductOutOfStockException(long productId)
{
ProductId = productId;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/extensibility/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ You can even make your own mix of allowed routes by calling the alternate constr
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.

```c#
public class ReportsController : JsonApiController<Report, int>
public class ReportsController : JsonApiController<Report, long>
{
public ReportsController(IJsonApiOptions options, IResourceGraph resourceGraph,
ILoggerFactory loggerFactory, IGetAllService<Report, int> getAllService)
ILoggerFactory loggerFactory, IGetAllService<Report, long> getAllService)
: base(options, resourceGraph, loggerFactory, getAll: getAllService)
{
}
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/extensibility/repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ If you only need minor changes you can override the methods defined in `EntityFr

```c#
// Program.cs
builder.Services.AddScoped<IResourceRepository<Article, int>, ArticleRepository>();
builder.Services.AddScoped<IResourceReadRepository<Article, int>, ArticleRepository>();
builder.Services.AddScoped<IResourceWriteRepository<Article, int>, ArticleRepository>();
builder.Services.AddScoped<IResourceRepository<Article, long>, ArticleRepository>();
builder.Services.AddScoped<IResourceReadRepository<Article, long>, ArticleRepository>();
builder.Services.AddScoped<IResourceWriteRepository<Article, long>, ArticleRepository>();
```

In v4.0 we introduced an extension method that you can use to register a resource repository on all of its JsonApiDotNetCore interfaces.
Expand All @@ -26,7 +26,7 @@ A sample implementation that performs authorization might look like this.
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.

```c#
public class ArticleRepository : EntityFrameworkCoreRepository<Article, int>
public class ArticleRepository : EntityFrameworkCoreRepository<Article, long>
{
private readonly IAuthenticationService _authenticationService;

Expand Down
14 changes: 7 additions & 7 deletions docs/usage/extensibility/resource-definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ builder.Services.AddResourceDefinition<ArticleDefinition>();
> [!NOTE]
> Prior to the introduction of auto-discovery (in v3), you needed to register the resource definition on the container yourself:
> ```c#
> builder.Services.AddScoped<ResourceDefinition<Article, int>, ArticleDefinition>();
> builder.Services.AddScoped<ResourceDefinition<Article, long>, ArticleDefinition>();
> ```

## Customizing queries
Expand All @@ -41,7 +41,7 @@ For example, you may accept some sensitive data that should only be exposed to a
> To exclude fields unconditionally, [attribute capabilities](~/usage/resources/attributes.md#capabilities) and [relationship capabilities](~/usage/resources/relationships.md#capabilities) can be used instead.

```c#
public class UserDefinition : JsonApiResourceDefinition<User, int>
public class UserDefinition : JsonApiResourceDefinition<User, long>
{
public UserDefinition(IResourceGraph resourceGraph)
: base(resourceGraph)
Expand Down Expand Up @@ -100,7 +100,7 @@ Content-Type: application/vnd.api+json
You can define the default sort order if no `sort` query string parameter is provided.

```c#
public class AccountDefinition : JsonApiResourceDefinition<Account, int>
public class AccountDefinition : JsonApiResourceDefinition<Account, long>
{
public AccountDefinition(IResourceGraph resourceGraph)
: base(resourceGraph)
Expand Down Expand Up @@ -128,7 +128,7 @@ public class AccountDefinition : JsonApiResourceDefinition<Account, int>
You may want to enforce pagination on large database tables.

```c#
public class AccessLogDefinition : JsonApiResourceDefinition<AccessLog, int>
public class AccessLogDefinition : JsonApiResourceDefinition<AccessLog, long>
{
public AccessLogDefinition(IResourceGraph resourceGraph)
: base(resourceGraph)
Expand Down Expand Up @@ -159,7 +159,7 @@ public class AccessLogDefinition : JsonApiResourceDefinition<AccessLog, int>
The next example filters out `Account` resources that are suspended.

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

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

```c#
public class ItemDefinition : JsonApiResourceDefinition<Item, int>
public class ItemDefinition : JsonApiResourceDefinition<Item, long>
{
public ItemDefinition(IResourceGraph resourceGraph)
: base(resourceGraph)
Expand Down
20 changes: 10 additions & 10 deletions docs/usage/extensibility/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In simple cases, you can also just wrap the base implementation with your custom
A simple example would be to send notifications when a resource gets created.

```c#
public class TodoItemService : JsonApiResourceService<TodoItem, int>
public class TodoItemService : JsonApiResourceService<TodoItem, long>
{
private readonly INotificationService _notificationService;

Expand Down Expand Up @@ -51,14 +51,14 @@ If you'd like to use another ORM that does not provide what JsonApiResourceServi
// Program.cs

// Add the service override for Product.
builder.Services.AddScoped<IResourceService<Product, int>, ProductService>();
builder.Services.AddScoped<IResourceService<Product, long>, ProductService>();

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

// ProductService.cs

public class ProductService : IResourceService<Product, int>
public class ProductService : IResourceService<Product, long>
{
private readonly IProductDao _dao;

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

```c#
public class ArticleService : ICreateService<Article, int>, IDeleteService<Article, int>
public class ArticleService : ICreateService<Article, long>, IDeleteService<Article, long>
{
// ...
}

// Program.cs
builder.Services.AddScoped<ICreateService<Article, int>, ArticleService>();
builder.Services.AddScoped<IDeleteService<Article, int>, ArticleService>();
builder.Services.AddScoped<ICreateService<Article, long>, ArticleService>();
builder.Services.AddScoped<IDeleteService<Article, long>, ArticleService>();
```

In v3.0 we introduced an extension method that you can use to register a resource service on all of its JsonApiDotNetCore interfaces.
Expand All @@ -140,7 +140,7 @@ Then on your model, pass in the set of endpoints to expose (the ones that you've
```c#
[Resource(GenerateControllerEndpoints =
JsonApiEndpoints.Create | JsonApiEndpoints.Delete)]
public class Article : Identifiable<int>
public class Article : identifiable<long>
{
// ...
}
Expand All @@ -149,11 +149,11 @@ public class Article : Identifiable<int>
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:

```c#
public class ArticlesController : JsonApiController<Article, int>
public class ArticlesController : JsonApiController<Article, long>
{
public ArticlesController(IJsonApiOptions options, IResourceGraph resourceGraph,
ILoggerFactory loggerFactory, ICreateService<Article, int> create,
IDeleteService<Article, int> delete)
ILoggerFactory loggerFactory, ICreateService<Article, long> create,
IDeleteService<Article, long> delete)
: base(options, resourceGraph, loggerFactory, create: create, delete: delete)
{
}
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Resource-specific metadata can be added by implementing `IResourceDefinition<TRe
```c#
#nullable enable

public class PersonDefinition : JsonApiResourceDefinition<Person, int>
public class PersonDefinition : JsonApiResourceDefinition<Person, long>
{
public PersonDefinition(IResourceGraph resourceGraph)
: base(resourceGraph)
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ options.ValidateModelState = true;
```c#
#nullable enable

public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Attr]
[MinLength(3)]
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/resource-graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ You can manually construct the graph.
```c#
// Program.cs
builder.Services.AddJsonApi(resources: resourceGraphBuilder =>
resourceGraphBuilder.Add<Person, int>());
resourceGraphBuilder.Add<Person, long>());
```

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

2. The `PublicName` property when a model is decorated with a `ResourceAttribute`.
```c#
[Resource(PublicName = "individuals")]
public class Person : Identifiable<int>
public class Person : identifiable<long>
{
}
```

3. The configured naming convention (by default this is camel-case), after pluralization.
```c#
// this will be registered as "people"
public class Person : Identifiable<int>
public class Person : identifiable<long>
{
}
```
Expand Down
18 changes: 9 additions & 9 deletions docs/usage/resources/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ If you want an attribute on your model to be publicly available, add the `AttrAt
```c#
#nullable enable

public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Attr]
public string? FirstName { get; set; }
Expand All @@ -24,7 +24,7 @@ There are two ways the exposed attribute name is determined:
2. Individually using the attribute's constructor.
```c#
#nullable enable
public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Attr(PublicName = "first-name")]
public string? FirstName { get; set; }
Expand All @@ -51,7 +51,7 @@ Otherwise, the attribute is silently omitted.
```c#
#nullable enable

public class User : Identifiable<int>
public class User : identifiable<long>
{
[Attr(Capabilities = ~AttrCapabilities.AllowView)]
public string Password { get; set; } = null!;
Expand All @@ -65,7 +65,7 @@ Indicates whether the attribute can be filtered on. When not allowed and used in
```c#
#nullable enable

public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Attr(Capabilities = AttrCapabilities.AllowFilter)]
public string? FirstName { get; set; }
Expand All @@ -79,7 +79,7 @@ Indicates whether the attribute can be sorted on. When not allowed and used in `
```c#
#nullable enable

public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Attr(Capabilities = ~AttrCapabilities.AllowSort)]
public string? FirstName { get; set; }
Expand All @@ -93,7 +93,7 @@ Indicates whether POST requests can assign the attribute value. When sent but no
```c#
#nullable enable

public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Attr(Capabilities = AttrCapabilities.AllowCreate)]
public string? CreatorName { get; set; }
Expand All @@ -107,7 +107,7 @@ Indicates whether PATCH requests can update the attribute value. When sent but n
```c#
#nullable enable

public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Attr(Capabilities = AttrCapabilities.AllowChange)]
public string? FirstName { get; set; };
Expand All @@ -124,7 +124,7 @@ You can also use [global options](~/usage/options.md#customize-serializer-option
```c#
#nullable enable

public class Foo : Identifiable<int>
public class Foo : identifiable<long>
{
[Attr]
public Bar? Bar { get; set; }
Expand All @@ -146,7 +146,7 @@ and retrieval.
```c#
#nullable enable

public class Foo : Identifiable<int>
public class Foo : identifiable<long>
{
[Attr]
[NotMapped]
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/resources/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class Person : Identifiable<Guid>
If you need to attach annotations or attributes on the `Id` property, you can override the virtual property.

```c#
public class Person : Identifiable<int>
public class Person : identifiable<long>
{
[Key]
[Column("PersonID")]
public override int Id { get; set; }
public override long Id { get; set; }
}
```

Expand Down
Loading