在ef核心上,我们可以使用..
加载图表DbContext.Player
.Include(a => a.Phones)
.Include(a => a.Addresses).ThenInclude(s => s.StateProvince).ThenInclude(c => c.CountryRegion)
.Include(a => a.EmailAddresses)
我正在尝试按如下方式构建动态图表。
var expression = "Phones;Addresses,EmailAddresses";
var includes = expression.Split(';', StringSplitOptions.RemoveEmptyEntries);
var q = DbContext.Set<Player>().AsQueryable();
foreach (var include in includes)
q = q.Include(include);
但我不能包含Address子相关实体,例如StateProvince和CountryRegion,因为我没有ThenInclude构造。
如何使用ef core动态包含子相关实体?