OData makes it very easy for us to pass query options from the URL down to an object mapper like EntityFramework. However, this somehow happens automagically and cannot be really controlled in code. In this blog post I show how we can extract and convert FilterQueryOption and OrderByQueryOption to manually apply them to our underlying LINQ provider. Let’s start with […]
ODATA provides several methods to validate the query options a client can specify. However it is not too easy to modify them, which might become necessary when we only want to allow certain options in relation to one another. In this article I will show how this can be done on a per request level or via an attribute. The […]
In our last post Separating your ODATA Models from the Persistence Layer with AutoMapper I showed how we can separate our public API Model from the internal persistence layer. In this post I will show how we can re-model the public API model without changing the internal data model. In the example from the previous post I showed our model […]
Normally when creating ODATA Controllers the external Model (such as Customer) pretty much maps to the internal database backed model when you are using an ORM such as EntityFramework. This can become problematik when you want to change the model / data format: We either have a (breaking) change on the ODATA REST API Or we have a database schema […]
Writing Odata Controllers usually involves a lot of boiler-plate code (and scaffolders are of no real help here either). However, when decoupling and unifying the business logic it is possible to also generalise the associated controllers and reduce their coding to a minimum. A typical Odata controller using IEntityManager (as described in Using Dependency Injection with StructureMap to decouple business […]
Today’s post title is rather lengthly so I keep the introduction short and come right to the point: when using OData (or any web services therefore) it can become quite hard to keep the actual business logic separate and not to mix things where they do not belong. At least for me, as I have to admit that this happened […]
While I was working with Excel of Office 365 I wanted to load and evaluate data from one of our Odata services we implemented. Suddenly I faced a strange issue: […]
Visual Studio supports the generation of data service clients (Service references) for OData services. A data service client is a .NET class that contains methods for accessing the OData service and gets generated based on the metadata provided by the OData service. The client acts as a proxy and translates the method calls into HTTP requests. Mike Wasson describes in […]
This blog post is a bit more lengthly than my usual posts and the idea came from an issue I faced when working in one of our project where we use an OData v3 REST interface that talks to an MS SQL Server (2012 R2) via EntityFramework v6.1.3. In short: we wanted to implement ‘entity framework row level security’ (in […]
Recently I ran into a strange error when working on an ODataController. On several occasions (especially on CREATE or UPDATE operations) we do not want to return the actual underlying entity of the controller, but instead would like to return an entity that can be used for synchronisation such as a Job. So instead of doing something like this and […]
When writing ODATA controllers for our projects we spend quite some time on writing boilerplate code and input parameter validation. In addition, for our error handling we would like detailed information for internal troubleshooting but not so detailed information sent back to the client (i.e. no stack traces). In order to achieve this without extra work we started looking at […]
In case you are still using LightSwitch and are not entirely relying on its internal features, you might have started using ODATA services as LightSwitch data sources. This comes in especially handy when combined with the Microsoft Managed Extensibility Framework (MEF) which lets you create decoupled components that can be easily plugged into your core application. However, as soon your […]
While working with OData controllers I came accross a challenge concerning authentication. The used authentication mode is Windows Authentication. I wanted to invoke an OData controller through a service reference from another OData controller with the user of the original call. The user of the original call has to be impersonated because the controller encapsulated as a service reference checks, […]
Today I would like to quickly present you how to unit test Web.API based OData Controllers the easy way. On biz.dfch.CS.Examples.Odata you find a complete code example and some accompanying information. The idea is based on the following information (and slightly enhanced): * Unit Testing Web API OData Services – Part 1 * Unit Testing Web API OData Services – […]
Introduction First, thank you all for your feedback to my first post, regarding the Extending the LightSwitch HTML client with a cascading push menu. Today I will show you, how […]
Recently I observed a strange behavior when working with an ODATA service via a “System.Data.Services.Client.DataServiceContext” that was wrapped inside a class library (via a regular “Service Reference”). The specific ODATA service in question was an Entity Framework v4.1 based service and had defined two different entity sets (“Objects” and “Tasks”) along with its regular CRUD operations. The specialty of the […]