The following expressions are equivalent (the arrow describes the preferred direction): No-op: - [ ] source.Skip(0) -> source - [x] source.Where(true) -> source Absorb: - [ ] source.Take(0).* -> source.Take(0) - [ ] source.Take(0) -> whatever.Take(0) - [ ] source.Where(false) <-> source.Take(0) Commutativity: - [x] source.OrderBy(x).Where(y) <-> source.Where(y).OrderBy(x) - [x] source.Where(x).Distinct() <-> source.Distinct().Where(x) Simplifications: - [x] source.Where(x).Where(y) -> source.Where(x && y) - [x] source.OrderBy(x).OrderBy(y) -> source.OrderBy(y) - [x] source.Take(x).Take(y) -> source.Take(Min(x, y)) https://github.com/dotnet/efcore/pull/35384 - [ ] source.Skip(x).Skip(y) -> source.Skip(Max(x, 0) + Max(y, 0)) - [ ] source.Take(x).Skip(y) -> source.Skip(y).Take(Max(x, 0) - Max(y, 0)) Operations on singletons: - [x] source.Distinct().Take(1) -> source.Take(1) https://github.com/dotnet/efcore/pull/34702 - [x] source.Take(1).Distinct() -> source.Take(1) https://github.com/dotnet/efcore/pull/34702 - [x] source.Take(1).OrderBy(x) -> source.Take(1) https://github.com/dotnet/efcore/pull/35214
The following expressions are equivalent (the arrow describes the preferred direction):
No-op:
Absorb:
Commutativity:
Simplifications:
LIMITs dotnet/efcore#35384Operations on singletons: