Allow filter include for non-collection properties
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with the issue's Organisation, Setting, and Location example and compare the existing collection filtered include with the requested conditional reference-property include. Done means EF Core can conditionally include Setting when its ApiKey matches, while preserving the existing collection behavior; no source files or tests are identified in the issue.
Written by the indexing model from the issue text.
Description
Given the following set of classes
public class Organisation
{
public Guid Id { get; set; }
public string Name { get; set; }
public List<Location> Locations { get; set; }
public Setting Setting { get; set; }
}
public class Setting
{
public string ApiKey { get; set; }
}
public class Location
{
public Guid Id { get; set; }
public Guid OrganisationId { get; set; }
public Organisation Organisation { get; set; }
public string Name { get; set; }
}
public class Db : DbContext
{
public DbSet<Organisation> Organisations { get; set; }
}
I would like to Include the Setting when querying the organisations only if the ApiKey matches a certain string.
At the moment filter include only works for collections, but not for object properties.
I would like to have something like If(Predicate predicate) to include the Settings Property in the Organisations query, example:
using (var database = new Db())
{
var organisations =
database
.Organisations
.Include(x => x.Locations.Where(l => l.Name.Contains("ABC"))) //This is possible now
.Include(x => x.Setting.If(l => l.ApyKey.Contains("XYZ"))) // This is what I would like to do
.Where(o => o.Name.Contains("OOO"))
.ToArray();
}
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100