private SortedDictionary <string, string> CreateFilterExpressions(FieldFilter[] filter) { // prepare a list of filter expressions SortedDictionary <string, string> list = new SortedDictionary <string, string>(); foreach (FieldFilter ff in filter) { string filterExpression = null; if (!(list.TryGetValue(ff.FieldName, out filterExpression))) { filterExpression = String.Empty; } else { filterExpression = (filterExpression + "\\0"); } if (ff.Value is Array) { object[] values = ((object[])(ff.Value)); if (ff.Operation == RowFilterOperation.Between) { ff.Value = String.Format("{0}$and${1}", DataControllerBase.ValueToString(values[0]), DataControllerBase.ValueToString(values[1])); } } else { ff.Value = DataControllerBase.ValueToString(ff.Value); } filterExpression = (filterExpression + (RowFilterAttribute.ComparisonOperations[Convert.ToInt32(ff.Operation)] + Convert.ToString(ff.Value).Replace("\'", "\\\'"))); list[ff.FieldName] = filterExpression; } return(list); }
private SortedDictionary <string, string> CreateFilterExpressions(FieldFilter[] filter) { // prepare a list of filter expressions SortedDictionary <string, string> list = new SortedDictionary <string, string>(); foreach (FieldFilter ff in filter) { string filterExpression = null; if (!(list.TryGetValue(ff.FieldName, out filterExpression))) { filterExpression = String.Empty; } else { filterExpression = (filterExpression + "\\0"); } if (ff.Value is Array) { object[] values = ((object[])(ff.Value)); if (ff.Operation == RowFilterOperation.Between) { ff.Value = String.Format("{0}$and${1}", DataControllerBase.ValueToString(values[0]), DataControllerBase.ValueToString(values[1])); } else if ((ff.Operation == RowFilterOperation.Includes) || (ff.Operation == RowFilterOperation.DoesNotInclude)) { StringBuilder svb = new StringBuilder(); foreach (object o in values) { if (svb.Length > 0) { svb.Append("$or$"); } svb.Append(DataControllerBase.ValueToString(o)); } ff.Value = svb.ToString(); } } else { ff.Value = DataControllerBase.ValueToString(ff.Value); } if (ff.Operation == RowFilterOperation.None) { filterExpression = null; } else { filterExpression = (filterExpression + (RowFilterAttribute.ComparisonOperations[Convert.ToInt32(ff.Operation)] + Convert.ToString(ff.Value).Replace("\'", "\\\'"))); } list[ff.FieldName] = filterExpression; } return(list); }