public string Handle(MethodCallExpression expression, Func<Expression, string> expressionWriter, ODataExpressionConverterSettings settings) { return string.Format( "{0} eq {1}", expressionWriter(expression.Object), expressionWriter(expression.Arguments[0])); }
public static string Write(object value, ODataExpressionConverterSettings settings) { if (value == null) { return("null"); } var type = value.GetType(); //if (type.IsEnum) //{ // return string.Format("{0}", (int)value); //} var writer = settings.ValueWriters.FirstOrDefault(x => x.Handles(type)); if (writer != null) { return(writer.Write(value, settings)); } if (typeof(Nullable <>).IsAssignableFrom(type)) { var genericParameter = type.GetGenericArguments()[0]; return(Write(Convert.ChangeType(value, genericParameter, CultureInfo.CurrentCulture), settings)); } return(value.ToString()); }
public static string Write(object value, ODataExpressionConverterSettings settings) { if (value == null) { return "null"; } var type = value.GetType(); //if (type.IsEnum) //{ // return string.Format("{0}", (int)value); //} var writer = settings.ValueWriters.FirstOrDefault(x => x.Handles(type)); if (writer != null) { return writer.Write(value, settings); } if (typeof(Nullable<>).IsAssignableFrom(type)) { var genericParameter = type.GetGenericArguments()[0]; return Write(Convert.ChangeType(value, genericParameter, CultureInfo.CurrentCulture), settings); } return value.ToString(); }
public ODataQueryProvider(IODataDataClient client, ODataExpressionConverterSettings settings) { this.Settings = settings; this.client = client; _expressionProcessor = new ExpressionProcessor(settings); _parameterBuilder = new ParameterBuilder(); }
public string Write(object value, ODataExpressionConverterSettings settings) { var enumType = value.GetType(); string assembly; string typename; settings.SerializationBinder.BindToName(enumType, out assembly, out typename); return string.Format("{0}'{1}'", typename, value); }
public string Write(object value, ODataExpressionConverterSettings settings) { var enumType = value.GetType(); string assembly; string typename; settings.SerializationBinder.BindToName(enumType, out assembly, out typename); return(string.Format("{0}'{1}'", typename, value)); }
public string Handle(MethodCallExpression expression, Func<Expression, string> expressionWriter, ODataExpressionConverterSettings settings) { var arguments = expression.Arguments.Select(x => expressionWriter(x)).ToList(); string objectValue = null; if (expression.Object != null) //instance method not static { objectValue = expressionWriter(expression.Object); } return odataFunction(objectValue, arguments, settings); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { settings.RegisterMember<DateTime>(nameof(DateTime.Date)); settings.RegisterMember<DateTime>(nameof(DateTime.Day)); settings.RegisterMember<DateTime>(nameof(DateTime.Year)); settings.RegisterMember<DateTime>(nameof(DateTime.Hour)); settings.RegisterMember<DateTime>(nameof(DateTime.MaxValue), "maxdatetime"); settings.RegisterMember<DateTime>(nameof(DateTime.Minute)); settings.RegisterMember<DateTime>(nameof(DateTime.MinValue), "mindatetime"); settings.RegisterMember<DateTime>(nameof(DateTime.Month)); settings.RegisterMember<DateTime>(nameof(DateTime.Now)); settings.RegisterMember<DateTime>(nameof(DateTime.Second)); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { settings.RegisterMember <DateTime>(nameof(DateTime.Date)); settings.RegisterMember <DateTime>(nameof(DateTime.Day)); settings.RegisterMember <DateTime>(nameof(DateTime.Year)); settings.RegisterMember <DateTime>(nameof(DateTime.Hour)); settings.RegisterMember <DateTime>(nameof(DateTime.MaxValue), "maxdatetime"); settings.RegisterMember <DateTime>(nameof(DateTime.Minute)); settings.RegisterMember <DateTime>(nameof(DateTime.MinValue), "mindatetime"); settings.RegisterMember <DateTime>(nameof(DateTime.Month)); settings.RegisterMember <DateTime>(nameof(DateTime.Now)); settings.RegisterMember <DateTime>(nameof(DateTime.Second)); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { settings.RegisterMethod <string>(nameof(string.Contains)); settings.RegisterMethod <string>(nameof(string.EndsWith)); settings.RegisterMethod <string>(nameof(string.StartsWith)); settings.RegisterMethod <string>(nameof(string.IndexOf)); settings.RegisterMethod <string>(nameof(string.ToLower)); settings.RegisterMethod <string>(nameof(string.ToLowerInvariant), "tolower"); settings.RegisterMethod <string>(nameof(string.ToUpper)); settings.RegisterMethod <string>(nameof(string.ToUpperInvariant), "toupper"); settings.RegisterMethod <string>(nameof(string.Trim)); settings.RegisterMember <string>(nameof(string.Length)); settings.RegisterValueWriter <string>(x => $"'{x}'"); }
public string Handle(MethodCallExpression expression, Func<Expression, string> expressionWriter, ODataExpressionConverterSettings settings) { var firstArg = expressionWriter(expression.Arguments[0]); var method = expression.Method.Name.ToLowerInvariant(); string parameter = null; var lambdaParameter = expression.Arguments[1] as LambdaExpression; if (lambdaParameter != null) { var first = lambdaParameter.Parameters.First(); parameter = first.Name ?? first.ToString(); } var predicate = expressionWriter(expression.Arguments[1]); return string.Format("{0}/{1}({2}:{3})", firstArg, method, parameter, predicate); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { settings.RegisterMethod<string>(nameof(string.Contains)); settings.RegisterMethod<string>(nameof(string.EndsWith)); settings.RegisterMethod<string>(nameof(string.StartsWith)); settings.RegisterMethod<string>(nameof(string.IndexOf)); settings.RegisterMethod<string>(nameof(string.ToLower)); settings.RegisterMethod<string>(nameof(string.ToLowerInvariant), "tolower"); settings.RegisterMethod<string>(nameof(string.ToUpper)); settings.RegisterMethod<string>(nameof(string.ToUpperInvariant), "toupper"); settings.RegisterMethod<string>(nameof(string.Trim)); settings.RegisterMember<string>(nameof(string.Length)); settings.RegisterValueWriter<string>(x => $"'{x}'"); }
public string Write(object value, ODataExpressionConverterSettings settings) { return odataFunction(value, settings); }
public ExpressionWriter(ODataExpressionConverterSettings settings) { this.settings = settings; }
public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings) { return expression.Member.Name.ToLowerInvariant(); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { settings.RegisterMethod(typeof(Math), nameof(Math.Floor)); settings.RegisterMethod(typeof(Math), nameof(Math.Ceiling)); settings.RegisterMethod(typeof(Math), nameof(Math.Round)); }
public string Handle(MethodCallExpression expression, Func <Expression, string> expressionWriter, ODataExpressionConverterSettings settings) { var arguments = expression.Arguments.Select(x => expressionWriter(x)).ToList(); string objectValue = null; if (expression.Object != null) //instance method not static { objectValue = expressionWriter(expression.Object); } return(odataFunction(objectValue, arguments, settings)); }
public string Write(object value, ODataExpressionConverterSettings settings) { return(odataFunction(value, settings)); }
public override string Write(object value, ODataExpressionConverterSettings settings) { var boolean = (bool)value; return(boolean ? "true" : "false"); }
public string Handle(MethodCallExpression expression, Func <Expression, string> expressionWriter, ODataExpressionConverterSettings settings) { return(string.Format( "{0} eq {1}", expressionWriter(expression.Object), expressionWriter(expression.Arguments[0]))); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { settings.RegisterValueWriter(new GuidValueWriter()); }
public string Write(object value, ODataExpressionConverterSettings settings) { Guid guid = (Guid)value; return(string.Format("guid'{0}'", guid.ToString().ToLower())); }
public string Write(object value, ODataExpressionConverterSettings settings) { Guid guid = (Guid)value; return string.Format("guid'{0}'", guid.ToString().ToLower()); }
public ExpressionProcessor(ODataExpressionConverterSettings settings) : this(settings, new ExpressionWriter(settings)) { }
public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings) { return(expression.Member.Name.ToLowerInvariant()); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { settings.RegisterMethod(typeof(Enum), nameof(Enum.HasFlag), (opj, args) => $"{opj} has {args.Single()}"); settings.RegisterValueWriter(new EnumValueWriter()); }
internal static void RegisterWriters(ODataExpressionConverterSettings settings) { }
public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings) { return(odataFunction(settings)); }
public override string Write(object value, ODataExpressionConverterSettings settings) { var base64 = Convert.ToBase64String((byte[])value); return(string.Format("X'{0}'", base64)); }
public string Handle(MethodCallExpression expression, Func <Expression, string> expressionWriter, ODataExpressionConverterSettings settings) { var firstArg = expressionWriter(expression.Arguments[0]); var method = expression.Method.Name.ToLowerInvariant(); string parameter = null; var lambdaParameter = expression.Arguments[1] as LambdaExpression; if (lambdaParameter != null) { var first = lambdaParameter.Parameters.First(); parameter = first.Name ?? first.ToString(); } var predicate = expressionWriter(expression.Arguments[1]); return(string.Format("{0}/{1}({2}:{3})", firstArg, method, parameter, predicate)); }
public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings) { return odataFunction(settings); }
public abstract string Write(object value, ODataExpressionConverterSettings settings);
public ExpressionProcessor(ODataExpressionConverterSettings settings, IExpressionWriter writer) { this.settings = settings; _writer = writer; }