Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 449 Bytes

File metadata and controls

19 lines (12 loc) · 449 Bytes

GCop 314

"You don't need the Where clause. Replace with foo.FirstOrDefault(...)"

Rule description

Using Where with FirstOrDefault clause or using FistOrDefault alone will make the same SQL statement. While the second approach is shorter and more meaningful.

Example

var myObj = foo.Where(a => a.Id == id).FirstOrDefault();

should be 🡻

var myObj = foo.FirstOrDefault(a => a.Id == id);