Include With Where Clause

DZone 's Guide to

Include With Where Clause

In this article, take a look at a tutorial that explains how to write a certain query in Entity Framework.

· Database Zone ·
Free Resource

Ever thought about writing the following query in Entity Framework?


In the above query, {{startdate}} and {{enddate}} are the parameters. This query will list all of the employees, but only the attendance that are between startdate and enddate. 

While working on a project, it seems very hard to do this using the standard EF Core library, so I found an online solution available I thought worth sharing.

A library has a lot of useful functionalities, including the one we are trying to solve, that can be downloaded from https://entityframework-plus.net/download.

While using that library's extension method IncludeFilter, the above query can be written in EF Core as follows:


StartDate and EndDate are the parameters that can be replaced by the parameter in your solutions.

Thanks for reading. Happy coding!

Further Reading

Bad Query Performance Tips Rebutted

Consider Using [NOT] EXISTS Instead of [NOT] IN

Quick Tip: Tracing Calls With Query Tags in Entity Framework Core 2.2

.net core ,code snippet ,database ,entity framework ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}