Len.StronglyTypedId
1.2.0
See the version list below for details.
dotnet add package Len.StronglyTypedId --version 1.2.0
NuGet\Install-Package Len.StronglyTypedId -Version 1.2.0
<PackageReference Include="Len.StronglyTypedId" Version="1.2.0" />
paket add Len.StronglyTypedId --version 1.2.0
#r "nuget: Len.StronglyTypedId, 1.2.0"
// Install Len.StronglyTypedId as a Cake Addin #addin nuget:?package=Len.StronglyTypedId&version=1.2.0 // Install Len.StronglyTypedId as a Cake Tool #tool nuget:?package=Len.StronglyTypedId&version=1.2.0
StronglyTypedId
A base implementation of strongly typed ids that supports Newtonsoft.Json, System.Text.Json, EntityFramework Core, and Swashbuckle.AspNetCore.
Getting started
- Install the package into your application or library.
Package Manager : Install-Package Len.StronglyTypedId
CLI : dotnet add package Len.StronglyTypedId
- Use record to define a strongly typed id:
[StronglyTypedId]
public partial record struct OrderId(Guid Value);
or
[StronglyTypedId]
public partial record OrderId(Guid Value);
Note: Only the record type is supported and cannot be nested, abstract, or generic.Support for serialization and deserialization of Newtonsoft.Json(version 13.0.0 or above) and System.Text.Json.
EntityFramework Core (version 7.0.0 or above)
Add the converter for a strongly typed id to the configuration of DbContext.
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
base.ConfigureConventions(configurationBuilder);
//...other
StronglyTypedIds.ApplyTo(configurationBuilder);
}
Swashbuckle.AspNetCore
Add the converter for a strongly typed id to the configuration of Swagger.
services.AddSwaggerGen(options =>
{
StronglyTypedIds.ApplyTo(options);
});
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Len.StronglyTypedId.Generators (>= 1.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.