JetBrains Rider 2026.1 Help

Code inspection: Replace with single call to FirstOrDefault(..)

This inspection reports a LINQ query that filters with Where(...) and then immediately calls FirstOrDefault(). The same query is shorter and clearer as a single FirstOrDefault(...) call.

Example

var item = items.Where(x => x.IsActive).FirstOrDefault();
var item = items.FirstOrDefault(x => x.IsActive);

Quick-fix

Replace the Where(...).FirstOrDefault() chain with FirstOrDefault(...).

29 March 2026