Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
父导航属性的C#表达式树参数_C#_Entity Framework_Lambda_Expression Trees - Fatal编程技术网

父导航属性的C#表达式树参数

父导航属性的C#表达式树参数,c#,entity-framework,lambda,expression-trees,C#,Entity Framework,Lambda,Expression Trees,如何为1 to*导航属性的父端创建ParameterExpression 以下内容适用于子实体: var parameter = Expression.Parameter( typeof(T), // where T is the entity type GetParameterName()); // helper method to get alias 在TParent上尝试类似的操作会生成一个源于上下文的查询,而不是作为子对象的属性 lambda等效值如下所示: var q

如何为1 to*导航属性的父端创建ParameterExpression

以下内容适用于子实体:

var parameter = Expression.Parameter(
    typeof(T), // where T is the entity type
    GetParameterName()); // helper method to get alias
在TParent上尝试类似的操作会生成一个源于上下文的查询,而不是作为子对象的属性

lambda等效值如下所示:

var q = from f in context.Foo 
        where f.Bar.BarId == 1...
         // where bar is the Navigation Property to the parent
为清晰起见进行编辑:

我使用以下命令从属性创建成员表达式:

Expression exp = Expression.Equal(
    Expression.Property(parameter, "SomeColumn"),
    Expression.Constant("SomeValue"));
因此,对于这种情况,我似乎应该使用MemberExpression而不是ParameterExpression。

我有点困惑。。。“.Bar”不是
参数表达式
-它是
成员表达式
f
是参数。你到底想做什么

请注意,一个选项是将示例代码加载到reflector中,打开.NET 3.5提示,然后阅读它是如何实现的-它看起来像代码,但通常很容易理解。

我有点困惑。。。“.Bar”不是
参数表达式
-它是
成员表达式
f
是参数。你到底想做什么

请注意,一个选项是将示例代码加载到reflector中,打开.NET3.5提示,然后阅读它是如何实现的-它看起来像代码,但通常很容易理解