Modifying ODataQueryOptions on the fly

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 […]

More Fun with your ODATA Models and AutoMapper

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 […]

LINQ to Entities and AutoMapper mapping conventions

The other day I was trying to map a class to some other class, nothing unusual – especially when we use AutoMapper for that task. However the error I got was really unexpected: Here is how my classes looked like: What happened? The error occurred when I tried to convert my Attribute to a NameValuePair […]

Separating your ODATA Models from the Persistence Layer with AutoMapper

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 […]

The strange case of the missing ExportedTypes

Assembly.ExportedTypes Exception

Recently I came across a strange error when trying to load an assembly into a Code Access Security (CAS) sandbox with C# (in a .NET 4.6.2 environment). I received a SecurityException with the dreaded Request failed. message when trying to access the ExportedTypes property on my assembly – something I would not think is possible […]

Using Generic Test Classes and EntityFramework test doubles to facilitate Unit Testing

This is some kind of follow-up to my previous posts regarding generic Odata controllers and decoupled domain managers. If you have followed my posts Using Dependency Injection with StructureMap to decouple business logic from WebApi OData Controllers and Simplifying OData Controllers by using generic controller classes you will remember that we use managers that contain […]

Simplifying OData Controllers by using generic controller classes

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 […]