Esempio n. 1
0
        protected override Expression VisitMemberAccess(MemberExpression m)
        {
            if (m.Expression != null)
            {
                if (m.Expression.NodeType == ExpressionType.Constant)
                {
                    SetValue(m.GetValue());
                    return m;
                }
                if (m.Expression.NodeType == ExpressionType.Parameter)
                {
                    _currentKey = (m.Member.Name == "Id") ? "objectId" : m.Member.Name;

                    if (typeof(IParseUser).IsAssignableFrom(m.Expression.Type))
                        _currentKey = ParseUserContract.ResolveName(_currentKey);

                    if (!_where.ContainsKey(_currentKey))
                    {
                        if (m.Member is PropertyInfo && ((PropertyInfo)m.Member).PropertyType == typeof(bool))
                        {
                            _where[_currentKey] = !_inversed;
                        }
                        else
                        {
                            _where[_currentKey] = null;
                        }
                    }
                    return m;
                }
            }
            throw new NotSupportedException(string.Format("The member '{0}' is not supported", m.Member.Name));
        }
Esempio n. 2
0
        protected override Expression VisitMemberAccess(MemberExpression m)
        {
            if (m.Expression != null)
             {
            if (m.Expression.NodeType == ExpressionType.Constant)
            {
               SetValue(m.GetValue());
               return m;
            }
            if (m.Expression.NodeType == ExpressionType.Parameter)
            {
               _currentKey = m.Member.Name;

               // Use JsonProperty if it exists..
               var jsonName = (Newtonsoft.Json.JsonPropertyAttribute)m.Member.GetCustomAttributes(false).FirstOrDefault(x => x is Newtonsoft.Json.JsonPropertyAttribute);
               if (jsonName != null)
               {
                   _currentKey = jsonName.PropertyName;
               }

               if (!_where.ContainsKey(_currentKey))
               {
                  if (m.Member is PropertyInfo && ((PropertyInfo) m.Member).PropertyType == typeof (bool))
                  {
                     _where[_currentKey] = !_inversed;
                  }
                  else
                  {
                     _where[_currentKey] = null;
                  }
               }
               return m;
            }
             }
             throw new NotSupportedException(string.Format("The member '{0}' is not supported", m.Member.Name));
        }
Esempio n. 3
0
        private string ParseMemberAccess(MemberExpression memberExpression)
        {
            var column = _mapping.Select(_ => _.ComputeColumnStatement(memberExpression)).FirstOrDefault(_ => _ != null);

            return column != null
                ? column.ToString()
                : Parameters.Add(memberExpression.GetValue());
        }