Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization
0.1.0-preview.0.1.0
dotnet add package Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization --version 0.1.0-preview.0.1.0
NuGet\Install-Package Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization -Version 0.1.0-preview.0.1.0
<PackageReference Include="Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization" Version="0.1.0-preview.0.1.0" />
<PackageVersion Include="Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization" Version="0.1.0-preview.0.1.0" />
<PackageReference Include="Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization" />
paket add Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization --version 0.1.0-preview.0.1.0
#r "nuget: Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization, 0.1.0-preview.0.1.0"
#:package Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization@0.1.0-preview.0.1.0
#addin nuget:?package=Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization&version=0.1.0-preview.0.1.0&prerelease
#tool nuget:?package=Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization&version=0.1.0-preview.0.1.0&prerelease
Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization
AOT-compatible System.Text.Json converters for the query parameter abstractions of Pure.RelationalSchema.Storage.PureQL.Projection: IParameterType, IParameter and IListParameter.
Overview
Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions describes a value bound to a query parameter of Pure.RelationalSchema.Storage.PureQL.Projection: its PureQL type and its value as invariant cell text, or, for a list parameter, its list type and its items. Those parameters are meant to be stored or sent as data and turned into PureQL literals when the query runs.
This package makes them JSON. It converts the interfaces, not concrete types, so any implementation, such as those of Pure.RelationalSchema.Storage.PureQL.Projection.Parameters, is written the same way, and reading gives back an implementation of the interface. The converters read and write JSON directly with Utf8JsonReader and Utf8JsonWriter, without reflection, so they work under trimming and native AOT.
Installation
dotnet add package Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization
Public API
| Name | Namespace | Description |
|---|---|---|
PureQLParametersConverters |
Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization |
IEnumerable<JsonConverter>: the converters of IParameterType, IParameter and IListParameter, to add to JsonSerializerOptions.Converters |
The converters themselves are internal: PureQLParametersConverters is the only public type.
JSON format
Property names are fixed and camel case, whatever the PropertyNamingPolicy.
Parameter type
IParameterType is an object with its name and whether it is nullable:
{ "name": "decimal", "nullable": false }
Parameter
IParameter is an object with its type and its value, the cell text as a JSON string:
{ "type": { "name": "decimal", "nullable": false }, "value": "9.99" }
A typed null has the empty string as its value:
{ "type": { "name": "date", "nullable": true }, "value": "" }
List parameter
IListParameter adds its items, each a parameter of the item type:
{
"type": { "name": "stringList", "nullable": false },
"value": "[\"paid\",\"shipped\"]",
"items": [
{ "type": { "name": "string", "nullable": false }, "value": "paid" },
{ "type": { "name": "string", "nullable": false }, "value": "shipped" }
]
}
The default encoder of System.Text.Json writes the quotes inside value as "; that is the same JSON string.
Reading
type,nameandnullableare required, andvalueis required for a parameter. A missing property, or a value of the wrong JSON type,nullincluded, is aJsonException.- An object with
itemsreads as anIListParameter, even through theIParameterconverter, so a list of mixed parameters round-trips. Through theIListParameterconverter,itemsis required. - The
valueof a list parameter may be left out: it is informational, so it is then built from the items' values, as the list parameters ofPure.RelationalSchema.Storage.PureQL.Projection.Parametersbuild it (["paid","shipped"], and[]for an empty list). - Properties may come in any order. Unknown properties are skipped; when a property repeats, the last one wins.
- Names and values are read and written as they are, without parsing or validation: checking a type name or a value's cell text, and turning a parameter into a PureQL literal, belong to the implementations.
Usage
Add the converters to the options:
using System.Text.Json;
using System.Text.Json.Serialization;
using Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Serialization;
JsonSerializerOptions options = new JsonSerializerOptions();
foreach (JsonConverter converter in new PureQLParametersConverters())
{
options.Converters.Add(converter);
}
Then serialize parameters as their interface, not their concrete type, so that the converters are picked:
using Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions.Parameter;
using Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.ListParameter;
using Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Parameter;
using String = Pure.Primitives.String.String;
IParameter[] parameters =
[
new StringParameter(new String("Ada")),
new NullableDateParameter(),
new StringListParameter([new String("paid"), new String("shipped")]),
];
string json = JsonSerializer.Serialize(parameters, options);
IParameter[] read = JsonSerializer.Deserialize<IParameter[]>(json, options)!;
A parameter is written with the value it has when it is written: a relative one, such as CurrentDateParameter, reads back as a fixed date.
Native AOT
Under native AOT, give the options a source-generated context for the types you serialize, and serialize through its JsonTypeInfo. The converters in Converters take precedence over the generated metadata:
using System.Text.Json.Serialization.Metadata;
JsonSerializerOptions options = new JsonSerializerOptions
{
TypeInfoResolver = ParametersJsonContext.Default,
};
foreach (JsonConverter converter in new PureQLParametersConverters())
{
options.Converters.Add(converter);
}
JsonTypeInfo<IParameter[]> info =
(JsonTypeInfo<IParameter[]>)options.GetTypeInfo(typeof(IParameter[]));
string json = JsonSerializer.Serialize(parameters, info);
IParameter[] read = JsonSerializer.Deserialize(json, info)!;
[JsonSerializable(typeof(IParameter[]))]
internal sealed partial class ParametersJsonContext : JsonSerializerContext;
Design Principles
- Interface-preserving — the converters target the abstractions, so any implementation serializes the same way
- Mirrors the abstractions — one JSON property per interface property, values kept as cell text
- No validation — names and values are carried as they are; the implementations parse and check them
- AOT-compatible —
IsAotCompatible=true, no reflection - One public type —
PureQLParametersConverters; the converters are internal
Dependencies
Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions—IParameterType,IParameterandIListParameterPure.Primitives— theString,TrueandFalsevalues a read parameter holds
Target Frameworks
- .NET 8
- .NET 9
- .NET 10
Related packages
Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions— the interfaces converted herePure.RelationalSchema.Storage.PureQL.Projection.Parameters— their implementations, one per PureQL literal and list literalPure.RelationalSchema.Storage.PureQL.Projection— runs PureQL queries over stored relational data and binds their parameters
| 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Pure.Primitives (>= 3.7.0)
- Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions (>= 0.1.0-preview.0.2.0)
-
net8.0
- Pure.Primitives (>= 3.7.0)
- Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions (>= 0.1.0-preview.0.2.0)
-
net9.0
- Pure.Primitives (>= 3.7.0)
- Pure.RelationalSchema.Storage.PureQL.Projection.Parameters.Abstractions (>= 0.1.0-preview.0.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.0.1.0 | 110 | 11/1/2026 |