protected override Expression VisitMemberAccess(MemberExpression m) { ParameterExpression param = m.Expression as ParameterExpression; if (param != null) { if (CurrentLocation != WhereLocationEnum.LeftOperatorClause) { throw new NotSupportedException("Member position not supported"); } string fieldRefName = FieldUtility.ExtractFieldReferenceName(m.Member); if (fieldRefName != null) { _builder.Append(fieldRefName); return(m); } } if (m.Member.DeclaringType == typeof(QueryConstant)) { if (CurrentLocation != WhereLocationEnum.RightOperatorClause) { throw new NotSupportedException("Member position not supported"); } _builder.Append("@" + m.Member.Name); return(m); } if ((m.Member.DeclaringType == typeof(WIT.Field)) && (m.Member.Name == "Value")) { string fieldRefName; if (LinqRegexp.TryGetFieldRefNameFromExpression(m, out fieldRefName)) { _builder.AppendFormat("[{0}]", fieldRefName); return(m); } } throw new NotSupportedException(string.Format("The member '{0}' is not supported", m.Member.Name)); }
private void ProcessOrderClause(LambdaExpression lambda, bool isAscending) { if ((lambda.Parameters.Count != 1) || (!(lambda.Parameters[0] is ParameterExpression)) || (!IsAWorkItem(lambda.Parameters[0].Type))) { throw new InvalidOperationException("invalid order clase"); } Expression body = lambda.Body; MemberExpression me = body as MemberExpression; string fieldReference = null; if (me != null) { fieldReference = FieldUtility.ExtractFieldReferenceName(me.Member); if (fieldReference == null) { throw new InvalidOperationException("invalid order field"); } _builder.AddOrderClause(fieldReference, isAscending); return; } MethodCallExpression mc = body as MethodCallExpression; if (mc != null) { fieldReference = FieldUtility.ExtractWIFieldFromMethodCall(mc); if (fieldReference == null) { throw new InvalidOperationException("invalid order field"); } _builder.AddOrderClause(fieldReference, isAscending); } }