Monthly Archives: August 2014

MicroLite 5.2 Released

MicroLite 5.2.0 has been released on NuGet.

The release mainly focuses on improving the usability from a query perspective. To that end, we have added support for:

  • Querying results into Tuples
  • Querying results into read-only pocos

In addition, we have added extra methods to the SqlBuilder and made a couple of minor refinements to the dynamic IL generation.

We covered the changes with examples in the MicroLite 5.2 upcoming features post so see that for further details.

MicroLite 5.2 Beta

A beta for MicroLite 5.2.0 has been released on NuGet, please feel free to download it and check out the new features we mentioned in the MicroLite 5.2 upcoming features post.

If you find any bugs, please raise them in the GitHub Issues along with any necessary information to reproduce it (or better yet, a pull request with a failing unit test) and we’ll make sure it’s squashed before the final release.

We should still be on track to release the final 5.2 build on the 20th August 2014.

MicroLite 5.2 upcoming features

MicroLite 5.2 is currently in development, you can see the progress by checking the GitHub 5.2 Milestone

We’ll cover the changes in greater detail once MicroLite 5.2 has been released, however here’s a sneak preview of some of the changes:


We have added a callback action which can be registered when specifying an include:

At the moment, if you want to use the Include functionality and store the result in a field, you need to do something like this:

var includeCustomer = session.Include.Single<Customer>(12345);

... // Something which results in the query being executed

this.customer = includeCustomer.Value;

The new callback functionality will allow you to express that same logic like this:

    .OnLoad(include => this.customer = include.Value);

Read Only classes

Prior to MicroLite 5.2, we required that classes had an identifier mapped so that they could be used for select by Id, insert, update and delete calls. We added the dynamic projection support to allow ad-hoc select queries but sometimes it is still nice to have a typed class. Also, dynamics are not supported in .NET 3.5 so the .NET 3.5 build of MicroLite does not offer it.

To remove this limitation, we are adding support for read only classes.

If you are using the Attribute Based Mapping, simply don’t decorate the class with the [Identifier(IdentifierStrategy.DbGenerated)] attribute.

If you are using the Convention Based Mapping, don’t add an Id or {Class}Id property.

// Convention mapped read-only class (no identifier required)
public class CustomerSummary
    public string Name { get; set; }
    public int Age { get; set; }

Example usage:

var sqlQuery = new SqlQuery(
    "SELECT Name, Age FROM Customer WHERE CustomerId = @p0",

var customerSummary = session.Single<CustomerSummary>(sqlQuery);


Read only classes will be supported by the following methods:



MicroLite has had support for dynamic projections since MicroLite 2.0 and the functionality was extended and simplified more recently in MicroLite 4.0.

In addition to dynamic results, we are now adding support for Tuples which will allow you to do the following:

var sqlQuery = new SqlQuery(
    "SELECT Name, Age FROM Customer WHERE CustomerId = @p0",

var tuple = session.Single<Tuple<int, string>>(sqlQuery);


Tuples will be supported for use in the following methods and will support singletons (one item) through to septuples (seven items) and be available in the .NET 4.0 and .NET 4.5 builds of MicroLite.


SQL Builder


var sqlQuery = sqlBuilder

This gives us the equivalent negative for .IsLike("FOO%").


var sqlQuery = sqlBuilder
    .NotBetween(1, 10)

This gives us the equivalent negative for .Between(1, 10).


var subQuery = new SqlQuery(
    "SELECT Id FROM Table WHERE Column = @p0",

var sqlQuery = sqlBuilder

var sqlQuery = sqlBuilder


var sqlQuery = sqlBuilder

The aim is to have MicroLite 5.2 finished by 20th August 2014, keep an eye out for it on