Len.StronglyTypedId.SystemTextJson
1.0.2
dotnet add package Len.StronglyTypedId.SystemTextJson --version 1.0.2
NuGet\Install-Package Len.StronglyTypedId.SystemTextJson -Version 1.0.2
<PackageReference Include="Len.StronglyTypedId.SystemTextJson" Version="1.0.2" />
paket add Len.StronglyTypedId.SystemTextJson --version 1.0.2
#r "nuget: Len.StronglyTypedId.SystemTextJson, 1.0.2"
// Install Len.StronglyTypedId.SystemTextJson as a Cake Addin
#addin nuget:?package=Len.StronglyTypedId.SystemTextJson&version=1.0.2
// Install Len.StronglyTypedId.SystemTextJson as a Cake Tool
#tool nuget:?package=Len.StronglyTypedId.SystemTextJson&version=1.0.2
StronglyTypedId
A base implementation of strongly typed ids.
Getting started
Install the standard Nuget package into your application or library.
Package Manager : Install-Package Len.StronglyTypedId -Version 1.0.2 CLI : dotnet add package --version 1.0.2 Len.StronglyTypedId
Use record to define strongly-typed ids:
public record struct OrderId(Guid Value) : IStronglyTypedId<Guid> { public static IStronglyTypedId<Guid> Create(Guid value) => new OrderId(value); }
or
public record OrderId(Guid Value) : IStronglyTypedId<Guid> { public static IStronglyTypedId<Guid> Create(Guid value) => new OrderId(value); }
System.Text.Json (STJ) or Newtonsoft
If you need to use strongly typed ids as output parameters for back-end interfaces in ASP. Net Core applications, you need to perform the following steps:
Install the System.Text.Json (STJ) package or Newtonsoft package into the ASP.NET Core program.
Package Manager : Install-Package Len.StronglyTypedId.SystemTextJson -Version 1.0.2 CLI : dotnet add package --version 1.0.2 Len.StronglyTypedId.SystemTextJson
or
Package Manager : Install-Package Len.StronglyTypedId.NewtonsoftJson -Version 1.0.2 CLI : dotnet add package --version 1.0.2 Len.StronglyTypedId.NewtonsoftJson
Note: Only one of them can be selected.
Enable strongly typed ids in the JsonOptions configuration.
services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.UseStronglyTypedId(); });
or
services.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.UseStronglyTypedId(); });
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net7.0
- Len.StronglyTypedId (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|