Cohesive.Adapters.AspNet
0.1.0-alpha.5
dotnet add package Cohesive.Adapters.AspNet --version 0.1.0-alpha.5
NuGet\Install-Package Cohesive.Adapters.AspNet -Version 0.1.0-alpha.5
<PackageReference Include="Cohesive.Adapters.AspNet" Version="0.1.0-alpha.5" />
<PackageVersion Include="Cohesive.Adapters.AspNet" Version="0.1.0-alpha.5" />
<PackageReference Include="Cohesive.Adapters.AspNet" />
paket add Cohesive.Adapters.AspNet --version 0.1.0-alpha.5
#r "nuget: Cohesive.Adapters.AspNet, 0.1.0-alpha.5"
#:package Cohesive.Adapters.AspNet@0.1.0-alpha.5
#addin nuget:?package=Cohesive.Adapters.AspNet&version=0.1.0-alpha.5&prerelease
#tool nuget:?package=Cohesive.Adapters.AspNet&version=0.1.0-alpha.5&prerelease
Cohesive.Adapters.AspNet
ASP.NET Core endpoint and request-binding adapters for Cohesive APIs, entities, relations, processes, and identity context.
Install
dotnet add package Cohesive.Adapters.AspNet
Use When
- You want to expose Cohesive API declarations through ASP.NET Core endpoints.
- You need route builders for entity operations, relation queries, process execution, or process status.
- You want ASP.NET request identity and scope policy enforcement to flow into Cohesive operation context.
Example
using Cohesive.Adapters.AspNet.Entities;
using Cohesive.Api;
using Microsoft.AspNetCore.Http;
var api = Api.Define("Notes");
var getNote = api.Entity<NoteResource>()
.Query("Get")
.Route("GET", "/notes/{id}")
.RouteParameter<string>("id")
.Returns<NoteResource>()
.Build();
app.MapEntityApiDefinition(api.Build(), new EntityApiEndpointOptions
{
Entity = NoteEntity.Instance.Definition
}
.Bind(getNote.Get(static (_, snapshot) =>
Results.Ok(ToResource(snapshot)))));
Canonical relation/query evaluation
Relation/query endpoints author a new RelationQueryEvaluation for each HTTP request and delegate the complete
compile-realize-plan-execute pipeline to IRelationQueryEvaluator. The request context supplies the evaluation
identity so runtime evidence, diagnostics, and traces remain correlated with the HTTP request. The result mapper is
required: the in-process evaluation outcome deliberately is not treated as a default wire contract.
using Cohesive.Adapters.AspNet.Relations;
using Cohesive.Model;
using Cohesive.Relations.Authoring;
using Cohesive.Relations.Execution;
// Configure an evaluator with the application's placement policy and source readers.
builder.Services.AddSingleton<IRelationQueryEvaluator>(relationQueryEvaluator);
var api = Api.Define("Transportation");
var loads = api.Action("SearchLoads")
.Route("GET", "/loads")
.Query<SearchLoadsRequest>()
.Returns<SearchLoadsResponse>()
.Build();
app.MapRelationQueryApiDefinition(api.Build(), new RelationQueryApiEndpointOptions()
.Bind(loads.RelationQuery(
(context, request) =>
{
var search = (SearchLoadsRequest)request!;
return loadsByCustomerDocument
.Evaluate(context.EvaluationId, loadShapeDocuments, relationshipCatalog)
.Set(customerNameParameterId, ObservationValue.FromString(search.CustomerName))
.Select(loadRowsId)
.Build();
},
(_, outcome) =>
{
if (outcome.Result is not { IsSuccessful: true } result)
return Results.UnprocessableEntity(outcome.Compilation.Diagnostics);
var rows = result.QueryResults.Single(branch => branch.Result == loadRowsId).Rows;
return Results.Ok(new SearchLoadsResponse(rows));
})));
EvaluationIdSelector can override the default aspnet/request/.../operation/... convention when an application
already has a stable correlation identity. The endpoint verifies that the per-request factory and evaluator preserve
the selected identity and passes one effective token, linking operation cancellation with
HttpContext.RequestAborted, through request binding, evaluation authoring, execution, and result mapping.
Entity-declared query endpoints use this same canonical binding rather than a repository-specific Entity query path. Map point reads and writes with the Entity adapter, then map the query endpoint from the same API definition with the Relations adapter. Each mapper emits only its bound endpoints, so the route is created exactly once:
var definition = api.Build();
app.MapEntityApiDefinition(definition, new EntityApiEndpointOptions
{
Entity = NoteEntity.Instance.Definition
}.Bind(noteGet.Get(static (_, snapshot) => Results.Ok(ToResource(snapshot)))));
app.MapRelationQueryApiDefinition(definition, new RelationQueryApiEndpointOptions()
.Bind(noteSearch.RelationQuery(
(context, request) => NoteQueries.Search(
context.EvaluationId,
(SearchNotesRequest)request!),
static (_, outcome) => MapSearchResponse(outcome))));
The required result mapper receives the complete canonical outcome, including rows, aggregations, requirement gaps, diagnostics, and provenance, and remains responsible for the endpoint's HTTP status policy.
Related Packages
Cohesive.Apifor semantic API declarations.Cohesive.Identityfor identity context and scope resolution.Cohesive.Processes,Cohesive.Relations, andCohesive.Storagefor the runtime surfaces exposed by endpoints.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Cohesive (>= 0.1.0-alpha.5)
- Cohesive.Api (>= 0.1.0-alpha.5)
- Cohesive.Host (>= 0.1.0-alpha.5)
- Cohesive.Identity (>= 0.1.0-alpha.5)
- Cohesive.Relations (>= 0.1.0-alpha.5)
- Cohesive.Storage (>= 0.1.0-alpha.5)
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-alpha.5 | 41 | 7/20/2026 |
| 0.1.0-alpha.4 | 51 | 7/13/2026 |
| 0.1.0-alpha.3 | 59 | 7/8/2026 |
| 0.1.0-alpha.2 | 62 | 7/7/2026 |