Mistakenly labelled duplicate - see answer below
Basic setup - I have an application context and an abstraction built to serve as the DAO:
SomeEntity:
public class SomeEntity
{
public string MyProp { get; set; }
}
DbContext:
public class ApplicationContext : DbContext
{
public DbSet<SomeEntity> SomeEntities { get; set; }
/* Rest of the DbContext doesn't matter. */
}
DAO:
public class DAO
{
private readonly DbSet<SomeEntity> _dbSet;
public DAO(ApplicationContext context)
{
_dbSet = context.SomeEntities;
}
public IEnumerable<SomeEntity> Where(Func<SomeEntity, bool> predicate)
{
return _dbSet.Where(predicate);
}
}
Usage:
Dao dao = new Dao(/* whatever for instantiation */);
var results = dao.Where(e => e.MyProp == "my string");
Expected behavior: I expect EF Core to generate a SQL query like:
SELECT [e].MyProp
FROM [TABLE_NAME] AS [e]
WHERE [e].MyProp = 'my string'
Actual behavior: EF Core generates the following SQL query:
SELECT [e].MyProp
FROM [TABLE_NAME] as [e]
It omits the where clause causing the application to pull every record into memory before filtering.
Why?