mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2025-12-06 05:56:10 +00:00
Fix eager includes not working
This commit is contained in:
@@ -200,6 +200,18 @@ namespace BasicSample
|
|||||||
Console.WriteLine($"Our users bought the following products starting with 'Red': {string.Join(", ", result.Ordered)}");
|
Console.WriteLine($"Our users bought the following products starting with 'Red': {string.Join(", ", result.Ordered)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var ret = dbContext.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.ThenInclude(x => x.Items)
|
||||||
|
.ThenInclude(x => x.Product)
|
||||||
|
.First();
|
||||||
|
Console.WriteLine($"User name: {ret.FullName}, Orders: {string.Join(", ", ret.Orders
|
||||||
|
.SelectMany(x => x.Items
|
||||||
|
.Select(y => y.Product.Name)
|
||||||
|
))}");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,6 +255,9 @@ namespace EntityFrameworkCore.Projectables.Services
|
|||||||
var properties = entityType.GetProperties()
|
var properties = entityType.GetProperties()
|
||||||
.Where(x => !x.IsShadowProperty())
|
.Where(x => !x.IsShadowProperty())
|
||||||
.Select(x => x.GetMemberInfo(false, false))
|
.Select(x => x.GetMemberInfo(false, false))
|
||||||
|
.Concat(entityType.GetNavigations()
|
||||||
|
.Where(x => !x.IsShadowProperty())
|
||||||
|
.Select(x => x.GetMemberInfo(false, false)))
|
||||||
// Remove projectable properties from the ef properties. Since properties returned here for auto
|
// Remove projectable properties from the ef properties. Since properties returned here for auto
|
||||||
// properties (like `public string Test {get;set;}`) are generated fields, we also need to take them into account.
|
// properties (like `public string Test {get;set;}`) are generated fields, we also need to take them into account.
|
||||||
.Where(x => projectableProperties.All(y => x.Name != y.Name && x.Name != $"<{y.Name}>k__BackingField"));
|
.Where(x => projectableProperties.All(y => x.Name != y.Name && x.Name != $"<{y.Name}>k__BackingField"));
|
||||||
|
|||||||
Reference in New Issue
Block a user