C#/.NET 0

Transient Error Handling with automatic Retries in C#

Inspired by Transient Fault Handling we created a quick helper class to faciliate the automatic retry of various operation that may fail in today’s interconnected environments. Large parts of our Appclusive framework deal with fetching from and pushing information to various backend systems. As they all can (and eventuall will) fail we needed a flexible approach on how to retry […]

C#/.NET 0

Creating SignalR Hub Classes on the fly

Recently I wanted to create SignalR hubs for client notification based on a list of internal queues. As SignalR is creating Hubs based on their type names I had to find an approach for dynamically defining classes based on the given queue list. In this blog post I show a way on how to do this The Situation In our […]

C#/.NET 0

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 specific environment, we are tasked […]

C#/.NET 0

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 to the Activity. Following the […]

C#/.NET 0

[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 class However, as by default […]

C#/.NET 27

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 LINQ provider. Let’s start with […]

C#/.NET 1

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 or via an attribute. The […]

C#/.NET 4

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 post I showed our model […]

C#/.NET 0

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 in an IQueryable call with […]

C#/.NET 0

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 the business logic and odata […]

C#/.NET 1

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 with StructureMap to decouple business […]

C#/.NET 0

[NoBrainer] C# and IEnumerable.ForEach

By default we cannot use ForEach() on IEnumerable but only on List. However, with extension methods to the rescue, it is easy to roll your own: Regarding the implementation I saw a few options: I could implement ForEach() with a traditional for loop, parallelise the operation, use ToList() to convert the list or other LINQ extensions such as Any() and […]