Introduction to Dapper.Net

Object Relational Mappers

If you're reading this, I assume that you know what an ORM is. If you don't: just imagine having a database with some tables that have columns. If you want to access that data in an application or a website (or ...) you need to have a representation of those tables in your code. That representation is usually reffered to as a collection of POCO's (plain old CLR objects).

To create these POCO's you usually have 2 choices:

  • You can create them yourself manually (create a POCO with its own properties for each table in your database, or for each table that you need in your application). You can then write custom code to map your database object to your POCO.
  • You can have these POCO's automatically created and mapped by an ORM.

For small applications, the former might be a good solution, but for applications that have huge databases with lots of tables and columns, orm's are most definitely the way to go. On top of automatically creating poco's for each table, ORM's also provide a so called "context" that tracks all changes done to a certain object. Having this context enables you to just fetch an item from your database, change some properties of the object and call SaveChanges() (or something like that, depending on the orm). Another key feature is that  they also allow you to use linq & lambda expressions, that in turn is converted/translated to SQL statements.

There are lots of ORMs for .NET, the most popular being Entity Framework, NHibernate and Linq2Sql (which is obsolete but still widely used). Orm's like Entity Framework obviously do more than what I've just described above here, and sometimes that causes an issue: performance. There are lots of articles on ORMS like Entity framework and how slow they are. If you're interested in the how and why, google is your best friend :) If you're already convinced that these popular ORM's are not doing it for you/your application, let me introduce you to

Dapper .NET

Dapper.NET is a micro ORM created by the same guys that run/created (that should give you some confidence in Dapper.NET already)

From Wikipedia:
"Dapper is a micro-ORM: it does not offer the full range of features of a full ORM such as nHibernate or Entity Framework. This is by design. It focuses on simplicity and performance rather than full automation. Dapper does not generate the SQL queries, but only maps the result to Plain Old CLR Objects (POCOs). Third party extensions are available for mapping objects to INSERT and UPDATE queries. It is optimized for use with .NET 4.0 or higher."

Basically what the above says is: if you dont need bloated and huge data models, and you require speed above anything else: go with something like Dapper.NET (there are other so called micro ORM's, like PetaPoco, Massive, Simple.Data,...)

How does it work?

You can install Dapper through Nuget (Install-Package Dapper).

Once you have it installed, you can get to work immediately. All you have to do is create a SqlConnection (in our case, but it works across all .net ado providers including sqlite, sqlce, firebird, oracle, MySQL, PostgreSQL and SQL Server)


Then create some classes (in this case I did it manually, but you can always use a T4 template to do this.


You're all set now, you can start querying.


The sample above showcases various scenarios:

  • First query will retrieve a list of deployments and automatically map them to the classes we created above.
  • Second query shows you how to use a where clause
  • Third query shows how you can use inner/left/..joins
  • All of the above queries were automatically mapped to a predefined class. This is not required, you can also just pass in an SQL statement. You will get back an object of type <dynamic> with all the values you requested.

There's obviously much more you can do with Dapper.NET, check their GitHub page for more info.

Apart from the easy usage, the key aspect ofcourse is speed/performance.

This is taken from Dapper.NET's GitHub page. More benchmarks are available there.

Performance of SELECT mapping over 500 iterations - POCO serialization

Hand coded (using a SqlDataReader) 47ms
Dapper ExecuteMapperQuery 49ms
ServiceStack.OrmLite (QueryById) 50ms
PetaPoco 52ms
BLToolkit 80ms
SubSonic CodingHorror 107ms
NHibernate SQL 104ms
Linq 2 SQL ExecuteQuery 181ms
Entity framework ExecuteStoreQuery 631ms


As you can see, Dapper's mapping from sql object to POCO is among the fastest around (granted, benchmarks always need to be taken with a grain of salt).

There are also some disadvantages. Because it is so lightweight, many feature that ORMs ship with are stripped out. There are no helpers for update / select and so on. This is imho the biggest drawback, although it is open source so if you want you can just add it in yourself!

Bottomline is: if you need something that is lightweight, fast, and easy to use: instead of going for Entity Framework or Linq2Sql like you usually do, try out something different and experiment a little with it!


Technology Technology

Op 02/07/2015 door Maarten

Using Lync to achieve your servicedesk SLA’s

Improve your first reply time and your customer satisfaction!

Is your team having troubles achieving the Service Level Agreement (= SLA) targets concerning first reply time? Do you want to improve your customer satisfaction? Then you’ve come to the right place! Customers expect everything to go faster and faster. Not only the quality of the first reply is important, providing it in a timely manner is too. Thats how our Customer Service Bot can help you.

The results speak for themselves

At Orbit One we wanted to improve our first reply time so we developed the customer service bot. In the graph below you can see how many tickets we received, that got a warning concerning the first reply time. A warning means that a ticket is almost about to exceed a SLA target regarding first reply time. The results speak for themselves. Since we started using our Customer Service Bot, the amount of warnings we received for tickets that were about to exceed the SLA went down with approximately 80%!

Graph of tickets first-reply time SLA warnings(1)

Can our customer service bot help you?

Are you using Microsoft Lync and Zendesk? Then we have a free out of the box solution for you! If you are using another ticketing system (JIRA, Freshdesk, hesk, kayako, etc…) please contact to see if we can help you.

How does it work?

Normally you have to check Zendesk manually every x minutes/hours to see if a new ticket has been created by a customer. Thanks to our customer service bot this belongs to the past! The customer service bot sends instant messages to inform you when something happens that requires action.

Zendesk integration

We use Zendesk views to get the tickets for different scenario’s. This means you can decide what the definition of a “new ticket” or “ticket without first reply” is. The agent and management groups are configurable in Zendesk, so you can decide who will get alerts. For more information, please download the application and read the documentation that comes with it.

Lync integration

The Lync api is used to send instant messages and start group conversations.

New tickets scenario

Below is a simplified version of the new tickets flow to give you a quick overview. As you can see, the bot sends an instant message from the moment a new ticket arrives.

  • The bot checks for new tickets every minute
  • If the responsible person is not available on Lync it starts a group conversation with the agents


This is a screenshot of what such a message looks like



First reply scenario

There is also the scenario where an agent forgets to reply to a ticket even if the initial message was delivered. For this scenario we invented the “first reply scenario”.

    • If a ticket has no first reply for too long, our bot will remind you that you need to respond

    • When you answer yes but forget to reply within a (configurable) given period of time it will remind you again.
    • If you don’t respond, the entire team will be notified




All configuration parameters can be managed in the configuration editor that comes with the customer service bot installation.




  • Highly configurable windows service

  • Service is extensible

  • Written in .NET

  • Integrates with Zendesk and Lync


  • Windows Vista, 7, 8, windows server 2008 + with .NET 4 installed

  • Lync server 2013

  • Zendesk

  • UCMA 4

For more information, please download the application and read the documentation that comes with it.

Orbit One offers the Lync Customer Service bot for free. You can download it yourself via our website. The Customer Service bot is a great example of our own Lync developments and Communication Enabled Business Processes.



Would you like help with the installation and configuration as well, or do you want custom adjustments? At Orbit One, we can help you with this (prepaid service).

Free tools Free tools

Op 07/01/2015 door Maarten

Dynamic applications through configuration

The scenario

 Imagine you have an application that connects to a CRM instance (this could be anything really, Sharepoint, Salesforce,..). Your application needs to get data from CRM, and in order to do that, it first needs to login.
Easy enough, you just create a method that connects to the datasource, hardcode the username, password and login link and you're all set. Why would any of those things ever change anyway? Passwords dont need to change. It's even better if they never do! 

How many times have you seen code like this? I hope not that much!

This might seem like a good idea in the beginning, and it might not even matter for a long time, but one day one of these things is inevitably going to change. And when they do, you're not going to want to dive into the code, change the data, recompile, and deploy again. It might seem like not that big of a deal to change this in the above example, but I think we all know how complex and terrifying (legacy) code can be.

Luckily there is a way to handle these kinds of situations. All applications, be it a website, console app, WCF,.. have a configuration file. This is an awesome place to configure stuff (that's probably also why they called it that way)

But how can we get data from the configuration file into our application? There are 2 ways to do that.

Custom ConfigSections

The first way we can handle this, is by specifying our own custom Section in the configSections of the configuration file. All we have to do is give it a decent name, and point it to the type and assembly. In this case the type is "CrmConfiguration", and the assembly is "Configuration".


In our custom configsection, we can define all the properties and keys we want. In the above example I have placed all the data that we previously hardcoded in the CrmConfiguration section.

The next thing we have to do, is create a class that will serve as a wrapper to fetch this information.


This is done in the above screenshot. All we do is basically create a public property for each of the keys we defined in the custom configuration section. This does not only make our application more dynamic, it also enables us to use strong typing.

We can now use the wrapper we created to login to the crmContext. As you can see in the screenshot below, all of the data is fetched from the configuration file.



Doesn't this look alot cleaner?


Regular AppSettings

The scenario above is actually a pretty good example of when you would want to create a custom configuration section. There are a decent amount of properties and it also makes the intent more clearer when just quickly looking through the config / code. It's possible though that you simply don't need to do something like this, and that all you want is a simple setting like "TestMode". If you're in a situation like this, there is also a way to create a dynamic and strong typed alternative to hardcoding stuff in code. Lets look at the example below:

We're still in the configuration file, but this time we did not define any custom configSections. All we did was add 2 keys to the AppSettings section, being TestMode and MailFrom. We can also create a wrapper class to fetch this data for us:



All we have to do is create a class with some public properties, and use the ConfigurationManager.AppSettings property to access they keys we need.

Below is an example of how you could use the wrapper class.



There are plenty of reason to use configuration files, the most important ones in my opinion are listed below:

  1. You can let an application continue to do its work, despite of some external changes (password, URL, ..) by simply editing the configuration file. No need to recompile / dive into code or deploy anything.
  2. The intent of your application will become much clearer. Having clearly defined sections/wrapper classes make it alot easier to get the big picture, than a bunch of inline strings spread across a codebase.
  3. You can change the entire runtime of your application (from instance from Test to Production) by simply changing a value in the .config file.




Technology Technology

Op 18/06/2014 door Maarten

Introducing Visual Studio 2013



Microsoft is moving fast these days. It only seems like a couple of months ago that I reluctantly started using Visual Studio 2012 ("a couple of months ago" being almost a year ago now..), and now we already have Visual Studio 2013.
Just like I wasn't really eager to switch from Visual Studio 2010 to Visual Studio 2012, I didn't really want to immediately switch to VS 2013 either. However, I decided to give it a try, and I must say that the VS team implemented some nice changes, and overall this feels like a bigger step functionality-wise than the changes between VS 2010 and VS 2012 (which were mostly visual/esthetic). I'll go into the parts I like best later on in this blogpost, but for now here's a general list of changes:


XAML design tools

  •     Rulers and guides. Drag visual guides from rulers to more precisely place elements and create custom layouts.
  •     Better style editing support. In-place style and template editing supports the creation and modification of templates directly in the context of the app display.
  •     Sample data support. Bind to sample data, including sample data in JSON format.
  •     View-state authoring. Modify view-state properties such as Edge and minimum widths for edge-aligned views directly in the Device panel.
  •     Behaviors. Add behaviors to your markup interactively by dropping them onto any element. Choose from a list of built-in behaviors or create custom behaviors.

SharePoint and Office

  •     MVC support. You can use the new MVC (model-view-controller) pattern in Office and SharePoint 2013 to create apps. In apps for SharePoint, you can choose the ASP.NET MVC Web Application as the web app for your project.
  •     Cloud Business App project template. Create line of business applications hosted on SharePoint for Office 365 that are based on Visual Studio LightSwitch technologies.
  •    Add search capabilities to your apps for SharePoint. You can deploy custom search configurations to a search-enabled site. See How to: Deploy custom search configurations by using Visual Studio.
  •     Debug remote event receivers and remote workflows. Remote event receivers and workflows contained in apps for SharePoint now support full debugging. See Developing apps for SharePoint on a remote system.


  •     Just My Code for C++ and JavaScript.
  •     Asynchronous call stacks are extended to show you the method chain that called the async code.
  •     64 bit Edit and Continue for .NET Framework code.
  •     You can now examine the return values of nested method calls.
  •     For more information, see What’s New for the Debugger in Visual Studio 2013.

(The full list can be seen here on MSDN.)


The 2 things that I like best however, are the following changes:


Visual studio "in the cloud"

I have been working with VS for almost 6 years now. I started with VS 2008, and gradually moved up to VS 2013 now. Over the last 6 years, I've worked on lots of different computers/laptops. A big hassle everytime I got a new/other development-machine, was that I needed to install/configure VS to my liking everytime again. One of the new features in VS 2013, is that you can "sign in" to VS, on any instance anywhere, and by doing that, your custom settings will be loaded in and be applied to VS. So this pretty basically solves the need to reconfigure VS everytime you get a new machine.


Another cool (and according to many people, really needed) feature, was the ability to choose the color theme out of the box. In previous versions of VS, this was not possible, and you needed to download a custom extension from the VS gallery (this was the case up until SP 2, after that it was integrated in VS aswell).


Although I'm happy that this made it into the newest version, I am kinda wondering why they needed to change the blue for this version. If you've been using the Blue theme since VS 2010, you'll notice that the blue theme kinda changed..Maybe the 'old" blue wasn't blue enough anymore for Microsoft? .. I have no idea.


CodeLens features

CodeLens isn't just some new feature, it's basically a game-changer. It will automatically show you how many references a certain method has and how many times and by who it has been changed in the past.
It's a direct integration with TFS which is extremely useful if you're doing lots of maintenance and debugging programming (like me). Combine this with some heavy ReSharper (alt+enter) magic, and you're basically good to go.

(I'm using the Visual Blend theme from this awesome site)


While this may be useful for certain types of programming (searching for bugs,maintenance,..), if you need to develop something new from scratch, there's not really much use for CodeLens (in my humble opinion). In that case, you can just as easily switch it off aswell.



I could go on about new stuff in VS for a lot longer than this, but I propose you just check it out yourself. You can download the express version from here. Or you could just nag to your boss :)


Technology Technology

Op 12/12/2013 door Maarten