LambdaLuke Help

Add the Get Single Result Endpoint

Add the Service Method

In the TaskService.cs file add the following method

public async Task<TaskDto?> GetTaskByIdAsync(int id) { using var conn = await _connectionFactory.CreateConnectionAsync(); var parameters = new DynamicParameters(); parameters.Add("@Id", id); var task = await conn.QuerySingleOrDefaultAsync<TaskDto>( "GetTaskById", parameters, commandType: CommandType.StoredProcedure ); return task; }

Add the Endpoint

In the TaskEndpoints.cs file add the following endpoint

app.MapGet("/api/tasks/{id:int}", async (int id, TaskService service) => { var task = await service.GetTaskByIdAsync(id); return task is not null ? Results.Ok(task) : Results.NotFound(); });

Test the Endpoint

In Postman or Rider etc

GET /api/tasks/1
12 July 2025