我试图使用IQueryable Include方法加载导航属性,但是虽然表达式是正确的我没有得到任何结果
这是代码
protected void LoadNavigationProperty(ref IQueryable<T> query, Expression<Func<T, object>>[] navigationProperties)
{
if ((query != null) && (navigationProperties != null))
{
foreach (Expression<Func<T, object>> navigationProperty in navigationProperties)
{
query.Include<T, object>(navigationProperty);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在查询上设置了一个断点.包括并检查数据:
navigationProperties[0] = { n => n.UserStatus }
navigationProperties[1] = { n => n.PrivilegeLevel }
Run Code Online (Sandbox Code Playgroud)
在单步执行包含行之后,我再次检查了查询值,发现它不包含导航属性