Bonelol / EntityFrameworkCore.IncludeFilter

Filter included entities in queries in EntityFramework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EntityFrameworkCore.IncludeFilter

Modified base on EntityFrameworkCore 2.1.0

How to use:

public void ConfigureServices(IServiceCollection services)
{ 
    ...

    services.AddDbContext<DbContext>(options => options.UseSqlServer("connection_string")
      .AddIncludeWithFilterMethods());

    ...
}
var children = dbContext.Parent.IncludeWithFilter(p=>p.Children, c=>c.Active)
                               .ThenIncludeWithFilter(c=>c.Items, i=>i.ID > 100);

NOTE: EF still performs identity resolution, results will be overwrite on next IncludeWithFilter call

About

Filter included entities in queries in EntityFramework

License:Other


Languages

Language:C# 100.0%