MicroLite 4.0 – Changes to Projections and Dynamics

In MicroLite 2.0, we introduced the Dynamic Projections feature and although useful, it did suffer from a couple of small limitations.

  • Firstly, it wasn’t compatible with the Include API so you had to perform 2 separate queries if you wanted to query a mapped class and also display a projection.
  • Secondly, you had to manually implement paging as projection had no paging capability.
  • Thirdly, it always retuned a collection so it was more effort to return a single record.

In order to address these limitations, the .Projection() method has been obsoleted and instead the dynamic keyword can be used the following methods:

ISession.Fetch<dynamic>(); // This is the direct replacement for ISession.Projection()

In addition to the change to dynamic support, the methods listed above can also be supplied with primitive types and a query which is restricted to a single column:

var dates = session.Fetch<DateTime>(new SqlQuery("SELECT Date FROM Table"));

This makes it much easier to use dynamic projections in your application.


2 thoughts on “MicroLite 4.0 – Changes to Projections and Dynamics

  1. Pingback: MicroLite 5.0 Released | MicroLite ORM

  2. Pingback: MicroLite 5.2 upcoming features | MicroLite ORM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s