1
如何爲1到*導航屬性的父級創建ParameterExpression?用於父導航的C#表達式樹參數屬性
的子實體以下工作:
var parameter = Expression.Parameter(
typeof(T), // where T is the entity type
GetParameterName()); // helper method to get alias
試穿TParent類似的東西產生的查詢源自語境,而不是對孩子的屬性。
拉姆達相當於會是這樣的:
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這種情況。