Merge pull request #17175 from obrenoalvim/fix/use-leftjoin-ef10
Some checks are pending
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
OpenAPI Publish / OpenAPI - Publish Artifact (push) Waiting to run
CodeQL / Analyze (csharp) (push) Waiting to run
Format / format-check (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
OpenAPI Publish / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI Publish / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / main (push) Waiting to run

Use Enumerable.LeftJoin for activity log user query
This commit is contained in:
Bond-009
2026-06-30 17:49:15 +02:00
committed by GitHub

View File

@@ -56,11 +56,11 @@ public class ActivityManager : IActivityManager
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false); var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
await using (dbContext.ConfigureAwait(false)) await using (dbContext.ConfigureAwait(false))
{ {
// TODO switch to LeftJoin in .NET 10. var entries = dbContext.ActivityLogs.LeftJoin(
var entries = from a in dbContext.ActivityLogs dbContext.Users,
join u in dbContext.Users on a.UserId equals u.Id into ugj a => a.UserId,
from u in ugj.DefaultIfEmpty() u => u.Id,
select new ExpandedActivityLog { ActivityLog = a, Username = u.Username }; (a, u) => new ExpandedActivityLog { ActivityLog = a, Username = u == null ? null : u.Username });
if (query.HasUserId is not null) if (query.HasUserId is not null)
{ {