Last Updated:

Minimal DAL and POCO mapping —Maximum minimum with Fluent ADO .NET

This time we will approach the mapping of POCO objects from a slightly different angle. There are situations when you should not use ORM for one reason or another, for example, the wishes of the customer or some other factors (for example, development for mobile devices).

What to do in this case? All that's left is ADO .NET with our favorite DbCommand and DbConnection.

And here is the way out! A lightweight library that allows you to use some of the advantages of ORM mapping without using ORM directly.

Her name is Fluent Ado.NET. Meet!

The official page of this miracle on Codeplex:

The source code can be taken here via SVN:

Compile downloaded sources. If you encounter errors during compilation, I advise you to remove references to test projects from the solution and make the rebuld again.

What do we have inside the solution? Four projects:

* FluentAdo.Generic

* FluentAdo.Oledb

* FluentAdo.Oracle

* FluentAdo.SQLite

I liked the first 🙂

By and large, the sources have written templates that you can easily duplicate in your main project. However, it is possible to use a ready-made library reference by connecting it to the project. Below we will consider the second option.

The entire SQL syntax will henceforth be under your watchful eye, you should not miss a single field. Most often, you'll be dealing with the FluentCommand class<> that executes a SQL query and maps the results. The command will need to specify an explicit connection similar to the following:


The classes from the DAL will remain the same (POCO):


And to make a selection from the database (of course, the database must be created), you need to write the following:


Here we have omitted GetSqlConnection because it is not relevant There is 😉

still a lot to think about, such as cascading table loading (Product <-> Order), as we did when using Fluent NHibernate.

But in general, the technology is very convenient, and if you do not want to use anything heavyweight, but on the contrary, want to get full control over Sql commands, query execution, etc., then FluentAdo .NET is for you.