Getting Instance by Type Name in StructureMap

Ever since we are using StructureMap we are also using this as a cheap replacement for Managed Extensibility Framework (MEF), as it allows us to scan arbitrary assembly paths for additional types to inject. As we are also dealing with configuration sections where we specify which plugins or types we want to use in a […]

Calling ResumeBookmark inside a TrackingParticipant returns NotFound

While creating a process with Windows Workflow Foundation we wanted to communicate between a workflow activity and the workflow application. For this we decided to use Bookmarks and a TrackingParticipant. The idea was that the Activity should create a bookmark to be consumed by a TrackingParticipant which would process something and then pass control back […]

[NoBrainer] Cascading Lambda Expression in C#

While Converting ODataQueryOptions into LINQ Expressions I needed to cascade different Lambda Expressions via AND and OR. In this post I describe a way on how to easily combine them via a boxing class with operator overriding. The Problem Cascading lambda expressions should be as easy as using a + or && operator: A boxing […]

[NoBrainer] Strongly typed caching with System.Runtime.Caching.MemoryCache

Caching with C# has become easy since the MemoryCache component is included in the .NET framework. While this implementation provides only limited functionality it is actually quite easy to make it strongly typed and support for constructing unique cache keys per cache group. In this post I will show you how this can be done […]

Converting ODataQueryOptions into LINQ Expressions in C#

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

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