© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
16 replies
SWEETPONY

Is it possible to remove predicate by condition?

I have following:
var notificationModels = await _repository
    .Query()
    .Where(model => DateTimeOffset.Now <= model.ExpiresAt)
    .Where(model => model.To
        .Contains(operatorName))
    .Where(model => model.Id <= arguments.LastNotificationId)
    .OrderByDescending(model => model.Id)
    .Limit(arguments.TotalCount)
    .ToList();
var notificationModels = await _repository
    .Query()
    .Where(model => DateTimeOffset.Now <= model.ExpiresAt)
    .Where(model => model.To
        .Contains(operatorName))
    .Where(model => model.Id <= arguments.LastNotificationId)
    .OrderByDescending(model => model.Id)
    .Limit(arguments.TotalCount)
    .ToList();


LastNotificationId
LastNotificationId
can be null or 0 and this case I wanna remove
.Where(model => model.Id <= arguments.LastNotificationId)
.Where(model => model.Id <= arguments.LastNotificationId)
and return just limited number of items
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

Is it possible to remove those methods ?
C#CC# / help
2y ago
✅ Is it possible to lock method by id?
C#CC# / help
3y ago
Possible race condition?
C#CC# / help
16mo ago