using System.Collections.Immutable; using Connected; using Connected.Entities; using Connected.Net.Endpoints; using Connected.ServiceModel; using Connected.Services; namespace Common.Net; /// /// Endpoints are singleton but their service is scoped so we must use Isolated database connections for all methods. /// internal sealed class QueryEndpoints : ServiceFunction?> { public QueryEndpoints(IEndpointCache cache) { Cache = cache; } private IEndpointCache Cache { get; } protected override async Task?> OnInvoke() { return await (from dc in Cache select dc).AsEntities(); } } internal sealed class SelectEndpoint : ServiceFunction, IEndpoint?> { public SelectEndpoint(IEndpointCache cache) { Cache = cache; } private IEndpointCache Cache { get; } protected override async Task OnInvoke() { return await (from dc in Cache where dc.Id == Arguments.Id select dc).AsEntity(); } }