© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
17 replies
barcode

✅ LINQ / EFCore

        var centers = await _dbContext.Centers
            .Include(x => x.Categories)
            .Where(x => x.CityId == request.CityId && (request.CategoryIds.Count == 0 ||
                                                       x.Categories.All(y => request.CategoryIds.Contains(y.Id))))
            .Include(x => x.Reviews)
            .DoThis(x.Rating = x.Reviews.Average(y=>y.Rating))
            .Skip(request.Page * request.Count)
            .Take(request.Count)
            .ToListAsync(cancellationToken: cancellationToken);
        var centers = await _dbContext.Centers
            .Include(x => x.Categories)
            .Where(x => x.CityId == request.CityId && (request.CategoryIds.Count == 0 ||
                                                       x.Categories.All(y => request.CategoryIds.Contains(y.Id))))
            .Include(x => x.Reviews)
            .DoThis(x.Rating = x.Reviews.Average(y=>y.Rating))
            .Skip(request.Page * request.Count)
            .Take(request.Count)
            .ToListAsync(cancellationToken: cancellationToken);

is this possible? I'm not sure how DoThis function is called
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ EFCore LINQ methods
C#CC# / help
3y ago
Efcore Dynamic Linq, AND and OR
C#CC# / help
4mo ago
LINQ
C#CC# / help
2y ago
❔ LINQ
C#CC# / help
3y ago