小编Jes*_*ham的帖子

IQueryable <T> .Include <T,object >>(Expression <Func <T,object >> not working

我试图使用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)

在单步执行包含行之后,我再次检查了查询值,发现它不包含导航属性

c# iqueryable navigation-properties

1
推荐指数
1
解决办法
1151
查看次数

标签 统计

c# ×1

iqueryable ×1

navigation-properties ×1