我知道如何创建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
我该怎么做?
答案 0 :(得分:2)
var parameter = Expression.Parameter(entityType, "entity");
// Expression: "entity.Property"
var property = Expression.Property(parameter, propertyName);
var subProperty = Expression.Property(property, subPropertyName);