Merge pull request #23821 from dotnet/main

merge to live
pull/24194/head^2
Rick Anderson 2021-11-09 07:10:33 -10:00 committed by GitHub
commit 7a809d4e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -196,7 +196,7 @@ We expect library authors to continue targeting `IHostBuilder`, `IWebHostBuilder
## Blazor
To adopt all of the new 6.0 features for Blazor apps, we recommend the following process:
To adopt all of the [new 6.0 features for Blazor apps](xref:aspnetcore-6.0#blazor), we recommend the following process:
* Create a new 6.0 Blazor project from one of the Blazor project templates. For more information, see <xref:blazor/tooling>.
* Move the app's components and code to the 6.0 app making modifications to adopt the new 6.0 features.

View File

@ -419,7 +419,7 @@ A DTO may be used to:
To demonstrate the DTO approach, update the `Todo` class to include a secret field:
[!code-csharp[](min-web-api/samples/6.x/todoDTO/Program.cs?name=snippet_secret&highlight=7)]
[!code-csharp[](min-web-api/samples/6.x/todoDTO/Program.cs?name=snippet_secret&highlight=6)]
The secret field needs to be hidden from this app, but an administrative app could choose to expose it.

View File

@ -28,7 +28,7 @@ app.MapPost("/todoitems", async (TodoItemDTO todoItemDTO, TodoDb db) =>
db.Todos.Add(todoItem);
await db.SaveChangesAsync();
return Results.Created($"/todoitems/{todoItem.Id}", todoItem);
return Results.Created($"/todoitems/{todoItem.Id}", new TodoItemDTO(todoItem));
});
#region snippet_put
@ -53,7 +53,7 @@ app.MapDelete("/todoitems/{id}", async (int id, TodoDb db) =>
{
db.Todos.Remove(todo);
await db.SaveChangesAsync();
return Results.Ok(todo);
return Results.Ok(new TodoItemDTO(todo));
}
return Results.NotFound();
@ -74,6 +74,7 @@ public class Todo
#region snippet_DTO
public class TodoItemDTO
{
public int Id { get; set; }
public string? Name { get; set; }
public bool IsComplete { get; set; }