Пример #1
0
        private static LambdaExpression GetPropertyLambdaExpression(ParameterExpression param, FilterRule rule)
        {
            var        propertyNames  = rule.Field.Split('.');
            Expression propertyAccess = param;
            var        type           = param.Type;

            foreach (var propertyName in propertyNames)
            {
                var property = type.GetProperty(propertyName);
                if (property == null)
                {
                    throw new KingsSharpException(string.Format(Resources.Filter_RuleFieldInTypeNotFound, rule.Field,
                                                                type.FullName));
                }
                type           = property.PropertyType;
                propertyAccess = Expression.MakeMemberAccess(propertyAccess, property);
            }
            return(Expression.Lambda(propertyAccess, param));
        }