C#C
C#3y ago
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();


LastNotificationId can be null or 0 and this case I wanna remove .Where(model => model.Id <= arguments.LastNotificationId) and return just limited number of items
Was this page helpful?