3

我知道如何创建一个MemberExpression例如entity.Property

// Expression: "entity"
var parameter = Expression.Parameter(entityType, "entity");

// Expression: "entity.Property"
var property = Expression.MakeMemberAccess(parameter, entityType.GetProperty(propertyName));

但我想创建一个MemberExpression访问子属性的,例如entity.Property.SubProperty

我该怎么做?

4

1 回答 1

2
  var parameter = Expression.Parameter(entityType, "entity");

   // Expression: "entity.Property"
   var property = Expression.Property(parameter, propertyName);
   var subProperty = Expression.Property(property, subPropertyName);
于 2013-03-08T15:33:16.120 回答