protected override Expression VisitBinary(BinaryExpression node) { if (QueryCollection.ContainsKey(Context)) { Append(" and "); } Visit(node.Left); Append(" "); switch (node.NodeType) { case ExpressionType.Equal: Append("eq"); break; case ExpressionType.NotEqual: Append("ne"); break; case ExpressionType.GreaterThan: Append("gt"); break; case ExpressionType.GreaterThanOrEqual: Append("ge"); break; case ExpressionType.LessThan: Append("lt"); break; case ExpressionType.LessThanOrEqual: Append("le"); break; /*case ExpressionType.AndAlso: * case ExpressionType.And: * Append("and"); * break;*/ case ExpressionType.OrElse: Append("or"); break; case ExpressionType.Not: Append("not"); break; } Append(" "); Visit(node.Right); return(node); }
private void Append(string value) { if (string.IsNullOrEmpty(Context)) { throw new Exception("OData expression must have a context."); } if (!QueryCollection.ContainsKey(Context)) { QueryCollection.Add(Context, value); } else { QueryCollection[Context] += value; } }
public ODataQuery GetQuery() { var query = new ODataQuery(); if (QueryCollection.ContainsKey("filter")) { query.Filter = QueryCollection["filter"]; } if (QueryCollection.ContainsKey("take")) { query.Take = int.Parse(QueryCollection["take"]); } return(query); }
private void Decode() { var fields = this.GetType().GetProperties().ToList(); foreach (var fieldInfo in fields) { try { if (QueryCollection.ContainsKey(fieldInfo.Name.ToLower())) { fieldInfo.SetValue(this, Convert.ChangeType(QueryCollection[fieldInfo.Name.ToLower()], fieldInfo.PropertyType)); } } catch { } } if (!string.IsNullOrEmpty(ConnectionData)) { ConnectionDatas = JsonConvert.DeserializeObject <List <ConnectionDataParameter> >(ConnectionData); } }