Automatic Query Short-Ciruiting
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
# What problem are you trying to solve?
Sometimes a query can be guaranteed to always return no results. In situations like that, the query should short-circuit and never get sent to the database server.
For Example:
```csharp
var items = (
from x in DbContext.Records
where IdsToFetch.Contains(x.Id)
select x
).ToList();
```
If ```IdsToFetch``` is empty, the query is guaranteed to return no results so it doesnt need to be sent to SQL.
# Describe the solution you'd like
If, client side, a query can be guaranteed to return no results, it should not be sent to the server.
The current alternative that I'm implementing is to manually decorate my code with ```if```s.
Contributor guide
Assessment
This issue has not been assessed yet.