Successful IoC container usage

Every now and again I here the meme of IoC containers being bad, they lead to bad developer practices, they’re too complicated and on and on. IoC containers – like any sharp tool – can be easily abused. Dependency injection, … Continue reading 

Posted in Dependency Injection, OO | 25 Comments

Avoid many-to-many mappings in ORMs

Going through and reviewing the Contoso University codebase, really to get caught up on EF 6 features, I found a relationship between two tables that resulted in a many-to-many mapping. We have these tables: A Course can have many Instructors, … Continue reading 

Posted in Entity Framework, NHibernate | 13 Comments

Efficient querying with LINQ, AutoMapper and Future queries

Even after all these years, I’m still a big fan of ORMs. One common complaint over the years is people using ORMs use the tool identically for both reads and writes. With writes, I want tracked entities, managed relationships, cascades … Continue reading 

Posted in AutoMapper, Entity Framework, LINQ | 30 Comments

Reducing NServiceBus Saga load

When presented with concurrency issues with NServiceBus sagas, you’re generally presented with two options: Relax the transaction isolation level Reduce worker thread count, forcing serialized processing of messages Both of these are generally not a great solution, as neither actually … Continue reading 

Posted in NServiceBus | 10 Comments

Converting AutoMapper to a Portable Class Library

In the early days of AutoMapper, I got requests to support AutoMapper in other platforms (mainly Silverlight). I didn’t have any experience in those other platforms, but I thought it would be easy. It was not. I wound up with … Continue reading 

Posted in AutoMapper | 5 Comments

Rendering ASP.NET content as PDF

I work on quite a few line of business applications, and a common ask is for printable reports. I could use a tool like SQL Server Reporting Services, but to be honest the report building and styling of those tools … Continue reading 

Posted in ASP.NET MVC | 33 Comments

Estimations in budgets and costs

It’s been many years since I’ve estimated feature effort in meaningless measurements, such as “story points” or “feature points”, and this makes me quite happy. Several years ago, on a long agile project, we estimated all effort in points. But … Continue reading 

Posted in Agile | 11 Comments

Proper Session/DbContext lifecycle management

Most “heavy” object-relational mappers (ORMs) have an interface that provides more than just easy querying of the database. They also are implementations of two key patterns: Unit of Work Identity Map For NHibernate, this is the ISession interface, and for … Continue reading 

Posted in Architecture, Patterns | 41 Comments

Put your controllers on a diet: POSTs and commands

Previous posts in this series: Redux Defactoring A survey GETs and queries In the last post, we looked at encapsulating the interesting part of GET actions (taking request parameters and building a model) into individual encapsulated query objects and handlers. … Continue reading 

Posted in Architecture, ASP.NET MVC, Patterns | 33 Comments

Null collections/arrays from MVC model binding

I’m firmly in the camp of the Framework Design Guidelines guidance on collection properties and return values: DO NOT return null values from collection properties or from methods returning collections. Return an empty collection or an empty array instead It … Continue reading 

Posted in ASP.NET MVC | 30 Comments