Skip to content

Commit 17fc22c

Browse files
committed
Fix eager includes not working
1 parent a36ada6 commit 17fc22c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

samples/BasicSample/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ public static void Main(string[] args)
200200
Console.WriteLine($"Our users bought the following products starting with 'Red': {string.Join(", ", result.Ordered)}");
201201
}
202202

203+
{
204+
var ret = dbContext.Users
205+
.Include(x => x.Orders)
206+
.ThenInclude(x => x.Items)
207+
.ThenInclude(x => x.Product)
208+
.First();
209+
Console.WriteLine($"User name: {ret.FullName}, Orders: {string.Join(", ", ret.Orders
210+
.SelectMany(x => x.Items
211+
.Select(y => y.Product.Name)
212+
))}");
213+
}
214+
203215
}
204216
}
205217
}

src/EntityFrameworkCore.Projectables/Services/ProjectableExpressionReplacer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ private Expression _AddProjectableSelect(Expression node, IEntityType entityType
255255
var properties = entityType.GetProperties()
256256
.Where(x => !x.IsShadowProperty())
257257
.Select(x => x.GetMemberInfo(false, false))
258+
.Concat(entityType.GetNavigations()
259+
.Where(x => !x.IsShadowProperty())
260+
.Select(x => x.GetMemberInfo(false, false)))
258261
// Remove projectable properties from the ef properties. Since properties returned here for auto
259262
// properties (like `public string Test {get;set;}`) are generated fields, we also need to take them into account.
260263
.Where(x => projectableProperties.All(y => x.Name != y.Name && x.Name != $"<{y.Name}>k__BackingField"));

0 commit comments

Comments
 (0)