Skip to content

Commit

Permalink
no tracking by default, and sort results
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfoneil committed Apr 21, 2024
1 parent f08ac46 commit 657c8d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ApiAuthDemo/ApiAuthDemo/Program.Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void MapApiEndpoints(this IEndpointRouteBuilder routeBuilder)
{
var (userName, _) = GetUserInfo(request);
db.UserName = userName;
return await db.Widgets.Where(row => row.CreatedBy == userName).ToListAsync();
return await db.Widgets.Where(row => row.CreatedBy == userName).OrderBy(row => row.Name).ToListAsync();
});

group.MapPost("/Widgets", async (ApplicationDbContext db, HttpRequest request, Widget data) =>
Expand Down
2 changes: 1 addition & 1 deletion ApiAuthDemo/ApiAuthDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
.AddIdentityCookies();

var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString));
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString).UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking));
builder.Services.AddDatabaseDeveloperPageExceptionFilter();

builder.Services.AddIdentityCore<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
Expand Down

0 comments on commit 657c8d7

Please sign in to comment.