79838571

Date: 2025-12-05 06:00:41
Score: 0.5
Natty:
Report link

I finaly found my answer here Delegate 'RequestDelegate' does not take 2 arguments - ASP.NET Core 8 Minimal API

When TypedResults are used i must specify the possible retursn in the lambda like async Task<Results<Ok<InternalGenericEmail>, NotFound<string>>> very important here to specify the type that takes eg return TypedResults.NotFound("hi") needs NotFound<string>

public void MapEndpoint(IEndpointRouteBuilder app) => app.MapGet("api/notifier/generic/check/{id}", async Task<Results<Ok<InternalGenericEmail>, NotFound<string>>> (string id, IEmailRepository emailRepository) =>
{
  IEnumerable<InternalGenericEmail> a = await emailRepository.GetAllAsync();
  InternalGenericEmail? result = a.FirstOrDefault(p => p.Id.ToString() == id);
  if (result is not null)
  {
    return TypedResults.Ok(result);
  }
  return TypedResults.NotFound($"Die angegebne Id: {id} ist nciht vorhanden");
}
  )
  .AddFluentValidationAutoValidation()
  .WithTags("Generic")
  .WithName($"GenericEmail123")
  .WithDescription("GenericEmailDesc")
  .WithSummary("GenericEmailSum")
  .Produces((int)HttpStatusCode.NoContent, null)
  .ProducesValidationProblem()
  ;
Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: FlorianD