OData filter options (handle null or empty values)

You can compare to null using the equality operator like this: $filter=CustomerID eq null In your case the query would degenerate to something like: $filter=(CustomerID eq null) or (null eq null) Which should work, but it’s not very nice. Did you consider removing the predicate completely in such case?

OData with ServiceStack? [closed]

Edit ServiceStack has now added Auto Query which is our approach to enabling data-driven services that avoids the pitfalls and anti-patterns promoted by OData. Will ServiceStack support OData. No. Not directly anyway. If anyone sees any value in OData they are free to add the necessary functionality as an optional Plugin – but it will … Read more

How to deserialize oData JSON?

Using Json.Net using (var client = new HttpClient()) { var json = await client.GetStringAsync(“http://services.odata.org/V3/OData/OData.svc/Products?$format=json”); var odata = JsonConvert.DeserializeObject<OData>(json); } public class Value { [JsonProperty(“odata.type”)] public string Type { set; get; } public int ID { get; set; } public string Name { get; set; } public string Description { get; set; } public DateTime ReleaseDate … Read more

What’s the right HTTP status code for a response when I can’t perform a DELETE due to a FK constrain?

Just found this website that says that ‘409 Conflict’ should be used when ‘the request could not be completed due to a conflict with the current state of the resource’ and ‘where it is expected that the user might be able to resolve the conflict and resubmit the request’, then it gives an example when … Read more

how to return json format from ODATA?

Download and install Fiddler. http://www.fiddler2.com/fiddler2/ Once installed, open it, click on the “Request Builder” tab located in the right side of Fiddler. Insert this URL: http://test.com/feed2/ODataService.svc/results Note that you DO NOT NEED THE ?$format=JSON In the “Request Headers” section, insert the following line: accept: application/json Hit the Big “Execute” button at the top right of … Read more

Select distinct values with odata

Currently the OData protocol doesn’t support the distinct operator, or any other operator which would help with such query (assuming you’re looking for disctinct values of a primitive property on some entity). You should be able to workaround this by implementing a service operation on the server which performs such query on the underlying provider … Read more

OData $filter with items in a $expand

The query you’ll need to write depends on the cardinality of the expanded collection. Here are some examples that use the public sample OData Northwind service, provided by odata.org. An order is always done by exactly one customer. Find the orders made by a customer with a specific name: http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$expand=Customer&$filter=Customer/CompanyName eq ‘Vins et alcools Chevalier’. … Read more

tech