/// <summary> /// Creates the <see cref="HttpRequestMessage"/>. /// </summary> /// <param name="args">The <see cref="IODataArgs"/>.</param> /// <param name="method">The HTTP method.</param> /// <param name="odataEntityName">The OData entity name.</param> /// <param name="url">The url path and query suffix.</param> internal HttpRequestMessage CreateRequestMessage(IODataArgs args, string method, string odataEntityName, string url) { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(HttpClient.BaseAddress.AbsolutePath)) { sb.Append(HttpClient.BaseAddress.AbsolutePath); sb.Append("/"); } if (!string.IsNullOrEmpty(odataEntityName)) { sb.Append(odataEntityName); } if (!string.IsNullOrEmpty(url)) { sb.Append(url); } var req = new HttpRequestMessage(new HttpMethod(method), new Uri(HttpClient.BaseAddress, sb.ToString())); if (args.HasHeaders) { for (int i = 0; i < args.Headers.Count; i++) { req.Headers.TryAddWithoutValidation(args.Headers.GetKey(i), args.Headers.GetValues(i)); } } args.RequestMessage = req; args.ResponseMessage = null; return(req); }
private IBoundClient <Model.Product> GetByArgs_OnQuery(IBoundClient <Model.Product> q, ProductArgs args, IODataArgs _) { return(q.FilterWildcard(p => p.Name, args?.Name) .FilterWildcard(p => p.Description, args?.Description)); }
/// <summary> /// Determines the HTTP Method to use. /// </summary> private string DetermineHttpMethod(string fallbackMethod, HttpMethod configuredMethod = null, IODataArgs odmArgs = null) { var m = odmArgs?.OverrideHttpMethod?.Method; if (m != null) { return(m); } m = configuredMethod?.Method; if (m != null) { return(configuredMethod.Method); } return(fallbackMethod); }
private IQueryable <Product> GetByArgs_OnQuery(IQueryable <Product> q, ProductArgs args, IODataArgs da) { return(q.WhereWildcard(p => p.Name, args?.Name) .WhereWildcard(p => p.Description, args?.Description)); }
private IQueryable <CustomerGroup> GetByArgsOnQuery(IQueryable <CustomerGroup> q, CustomerGroupArgs args, IODataArgs odataArgs) { return(q.WhereWith(args?.Company, a => a.Company == args.Company) .WhereWith(args?.Description, a => a.Description == args.Description)); }