protected override Expression VisitMember(MemberExpression m) { var param = m.Expression as ParameterExpression; if (IsInNotBlock) { throw new NotSupportedException("Not statement not supported"); } if (param != null && param.Name == _parameterName) { if (_resolver == null) { throw new NotSupportedException("Cannont resolve field"); } var field = _resolver.Resolve(m.Member); if (field == null) { throw new NotSupportedException("Non-mapped field not supported"); } _statement = new FieldStatement(field.Name, _origin); return(m); } if (m.Member.DeclaringType == typeof(QueryConstant)) { if (CurrentLocation != WhereLocation.RightOperatorClause) { throw new NotSupportedException("Member position not supported"); } _statement = new ParameterValueStatement(m.Member.Name); return(m); } throw new NotSupportedException($"The member '{m.Member.Name}' is not supported"); }
/// <summary> /// Processes the order clause. /// </summary> /// <param name="lambda">The lambda.</param> /// <param name="isAscending">if set to <c>true</c> [is ascending].</param> private void ProcessOrderClause(LambdaExpression lambda, bool isAscending) { if (lambda.Parameters.Count == 0) { throw new InvalidOperationException("invalid order clase"); } if (lambda.Parameters.Count != 1 || !IsAWorkItem(lambda.Parameters[0].Type)) { throw new InvalidOperationException("invalid order clase"); } var body = lambda.Body; var me = body as MemberExpression; if (me != null) { var fieldInfo = _resolver.Resolve(me.Member); if (fieldInfo == null) { throw new InvalidOperationException("invalid order field"); } _builder.AddOrderClause(fieldInfo.Name, isAscending); return; } var mc = body as MethodCallExpression; if (mc != null) { var fieldInfo = _resolver.Resolve(lambda.Parameters[0].Name, mc); if (fieldInfo == null) { throw new InvalidOperationException("invalid order field"); } _builder.AddOrderClause(fieldInfo.Name, isAscending); } }