Tag Archives: Release

MicroLite.Extensions.WebApi 6.6.0

The OData query parsing library which was spun out of the MicroLite WebApi extension has undergone quite a few changes and some of those have been incorporated into the MicroLite WebApi extension.

The main difference is that the OData query support has been split out into a separate library so if you want to use WebApi controllers but don’t use OData, you no longer have a dependency on the Net.Http.WebApi.OData library. Starting with version 6.6.0 of the MicroLite WebApi extension, there are now 2 packages available:

What do I need to do?

“I use the WebApi extension and want OData 4.0!”

  1. PM> Install-Package MicroLite.Extensions.WebApi.OData -Version 6.6.0

“I use the WebApi extension and don’t use OData query support”

  1. PM> Install-Package MicroLite.Extensions.WebApi -Version 6.6.0
  2. PM> Uninstall-Package Net.Http.WebApi.OData

Query Option Changes
$inlinecount=allpages has been replaced by $count=true.

The JSON response for paged results ($count=true) has changed as follows:

  1. data.__count is now data['@odata.count']
  2. data.results is now data.value

Function Changes
The substringof function has been replaced by contains in the $filter query option so substringof('Alfreds', CompanyName) would become contains(CompanyName, 'Alfreds')

Data Type Changes:
The DateTime type has been removed, there is a new Date type for dates only which is a literal and doesn’t need a type prefix or quotes $filter=DateOfBirth eq 1974-08-19. To specify date and time, use DateTimeOffset literal instead which also no longer requires a type prefix or quotes $filter=Created gt 2002-10-15T17:34:23Z don’t forget the timezone!.

The Guid type no longer requires a prefix or quotes TransactionId eq guid'0D01B09B-38CD-4C53-AA04-181371087A00' becomes TransactionId eq 0D01B09B-38CD-4C53-AA04-181371087A00

The library now requires the entity model to be defined, see the Wiki for further details.

MicroLite.Extensions.Mvc 6.3.0

MicroLite.Extensions.Mvc 6.3.0 has been released on NuGet.

The main changes in this release are:

  1. .NET 4.5 only build targeting ASP.NET MVC 5.2.3
  2. MicroLiteSessionAttribute has been removed, it is strongly recommended that you use an IOC container to manage dependencies.

This does mean that the release is not necessarily a “drop-in” update if you were previously using an older version of .NET or ASP.NET MVC.

To see the full set of changes, please refer to the Github release page

MicroLite.Extensions.WebApi 6.5.0

MicroLite.Extensions.WebApi 6.5.0 has been released on NuGet.

The main changes in this release are:

  1. .NET 4.5 only build targeting ASP.NET WebApi 5.2.3 and Net.Http.WebApi.OData 3.4.0
  2. MicroLiteSessionAttribute has been removed, it is strongly recommended that you use an IOC container to manage dependencies.

This does mean that the release is not necessarily a “drop-in” update if you were previously using an older version of .NET or ASP.NET WebApi.

To see the full set of changes, please refer to the Github release page

Logging Extension Updates

The logging extensions for MicroLite have been updated as follows and are available on nuget.org.

log4net

The log4net extension has been updated to target log4net 2.0.5 or later and a .NET 4.6 compiled build has been added.

NLog

The NLog extension has been updated to target NLog 4.4.0 or later and a .NET 4.6 compiled build has been added.

Serilog

The Serilog extension has been updated to target Serilog 2.3.0 or later, a .NET 4.6 compiled build has been added and the .NET 4.0 build has been removed.

MicroLite 6.3.1

MicroLite 6.3.1 has been released and it is strongly recommended that anyone using 6.3.0 upgrades immediately.

A defect has been identified in 6.3.0 whereby the Identifier value of a newly inserted record isn’t set on the object. This was inadvertently introduced when the Listener code was refactored in 6.3.0 so it only affects that version which has now been hidden on nuget.org.

Upgrading to MicroLite 6.3

MicroLite 6.3.0 has been released on NuGet, the main changes in this release are detailed below.

New Convention Mappings

There are now 2 new helper convention mappings:

  1. ConventionMappingSettings.LowercaseWithUnderscores – Maps a Pascal Cased property name to an underscore separated lower cased column e.g. a property called ‘CreditCard’ would map to a column called ‘credit_card’
  2. ConventionMappingSettings.UppercaseWithUnderscores – Maps a Pascal Cased property name to an underscore separated upper cased column e.g. a property called ‘CreditCard’ would map to a column called ‘CREDIT_CARD’

DateTime mapping

The default mapping for System.DateTime is now System.Data.DbType.DateTime2. If you need to change it back to System.Data.DbType.DateTime do the following:

// In startup code (before calling Configure.Fluently()...):

// Reset the DbType mapping for DateTime:
TypeConverter.RegisterTypeMapping(typeof(DateTime), DbType.DateTime);
TypeConverter.RegisterTypeMapping(typeof(DateTime?), DbType.DateTime);

XDocument mapping

The default mapping for System.Xml.Linq.XDocument is now System.Data.DbType.Xml. If you need to change it back to System.Data.DbType.String do the following:

// In startup code (before calling Configure.Fluently()...):

// Reset the DbType mapping for XDocument:
TypeConverter.RegisterTypeMapping(typeof(XDocument), DbType.String);

Upgrading to MicroLite 6.2

MicroLite 6.2.0 has been released on NuGet.

The 2 main changes in this release are:

  • The session re-uses the same command during its lifecycle so multiple operations via a session are more efficient – especially multiple operations of the same type (e.g. multiple inserts).
  • Improved the handling of TimeSpan – beware that this is a breaking change (see below)

Prior to MicroLite 6.2, MicroLite was able to map a TimeSpan to a MS SQL Time column – however it turns out there are a number of problems with the Time type:

  1. It has a maximum value of 24:00:00 since it is actually designed to represent the time of day
  2. It cannot be used in some aggregate functions such as SUM and AVERAGE which makes summarising data diffucult

In order to mitigate these issues, MicroLite 6.2 now maps TimeSpan to a BIGINT by persisting the tick count of the TimeSpan – this has the added benefit of also enabling TimeSpan to be used by any database supported by MicroLite.

If you are updating to MicroLite 6.2 and you are currently using TimeSpan -> TIME you have 2 options:

1) – Update your database schema to use a BIGINT (add a new column, populate it by casting the time as the tick count, remove the old column).

2) – Configure MicroLite 6.2 to behave like MicroLite 6.1:

// In startup code (before calling Configure.Fluently()...):

// 1. Remove the new TimeSpanTypeConverter:
var timeSpanTypeConverter = TypeConverter.Converters.OfType<TimeSpanTypeConverter>().Single();
TypeConverter.Converters.Remove(timeSpanTypeConverter);

// 2. Reset the DbType mapping for TimeSpan:
TypeConverter.RegisterTypeMapping(typeof(TimeSpan), System.Data.DbType.Time);
TypeConverter.RegisterTypeMapping(typeof(TimeSpan?), System.Data.DbType.Time);

Upgrading to MicroLite 6.1

There are a couple of changes in MicroLite 6.1 which you need to be aware of when updating from a previous version.

Listeners

In MicroLite 6.1, we have split the IListener interface into 3:

IDeleteListener containing the following methods:

void AfterDelete(object instance, int rowsAffected);
void BeforeDelete(object instance);

IInsertListener containing the following methods:

void AfterInsert(object instance, object executeScalarResult);
void BeforeInsert(object instance);

IUpdateListener containing the following methods:

void AfterUpdate(object instance, int rowsAffected);
void BeforeUpdate(object instance);

You can create as many listeners as you like implementing all or some of the above interfaces and register them in the appropriate collections.

Example – Create a listener which only cares about insert operations:

public class InsertOnlyListener : IInsertListener
{
   public void AfterInsert(object instance, int rowsAffected) { ... }
   public void BeforeInsert(object instance) { ... }
}

Listener.InsertListeners.Add(new MyInsertListener());

Example – Create a listener which cares about insert and update operations:

public class AuditListener : IInsertListener, IUpdateListener
{
   public void AfterInsert(object instance, int rowsAffected) { ... }
   public void AfterUpdate(object instance, int rowsAffected) { ... }
   public void BeforeInsert(object instance) { ... }
   public void BeforeUpdate(object instance) { ... }
}

var auditListener = new AuditListener();
Listener.InsertListeners.Add(auditListener);
Listener.UpdateListeners.Add(auditListener);

SQL Builder

The “write” builders (SqlBuilder.Delete and SqlBuilder.Update) now offer the same functionality for single columns as the read builder (SqlBuilder.Select):

  • Between(object lower, object upper);
  • In(params object[] args);
  • In(params SqlQuery[] subQueries);
  • In(SqlQuery subQuery);
  • IsEqualTo(object comparisonValue);
  • IsGreaterThan(object comparisonValue);
  • IsGreaterThanOrEqualTo(object comparisonValue);
  • IsLessThan(object comparisonValue);
  • IsLessThanOrEqualTo(object comparisonValue);
  • IsLike(object comparisonValue);
  • IsNotEqualTo(object comparisonValue);
  • IsNotLike(object comparisonValue);
  • IsNotNull();
  • IsNull();
  • NotBetween(object lower, object upper);
  • NotIn(params object[] args);
  • NotIn(params SqlQuery[] subQueries);
  • NotIn(SqlQuery subQuery);

Upgrading to MicroLite 6.0

There are a few changes in MicroLite 6.0 and some of the extensions which you need to be aware of when updating from a previous version.

The .NET 4.5 build now contains an Async version of the session api (IAsyncSession and IAsyncReadOnlySession). If you are using a .NET 4.5 app, I suggest you update to make full use of the async version. The MVC and WebApi extensions already exclusively make use of it (see further below for more details).

Here’s the .NET 4.5 async version of each session method:

.NET 4.0 API .NET 4.5 API
Read API
Session.Fetch(SqlQuery) await Session.FetchAsync(SqlQuery)
Session.Paged(SqlQuery) await Session.PagedAsync(SqlQuery)
Session.Single(obj) await Session.SingleAsync(obj)
Session.Single(SqlQuery) await Session.SingleAsync(SqlQuery)
Write API
Session.Delete(obj) await Session.DeleteAsync(obj)
Session.Insert(obj) await Session.InsertAsync(obj)
Session.Update(obj) await Session.UpdateAsync(obj)
Session.Advanced.Delete(Type, obj) await Session.Advanced.DeleteAsync(Type, obj)
Session.Advanced.Execute(SqlQuery) await Session.Advanced.ExecuteAsync(SqlQuery)
Session.Advanced.ExecuteScalar(SqlQuery) await Session.Advanced.ExecuteScalarAsync(SqlQuery)
Session.Advanced.Update(ObjectDelta) await Session.Advanced.UpdateAsync(ObjectDelta)

Attribute Mapping

If you use the attribute based mapping, the attributes are now in the MicroLite.Mapping.Attributes namespace rather than MicroLite.Mapping.

DbEncryptedString

The DbEncryptedString class and associated classes has moved to the new MicroLite.Extensions.Cryptography project

SQL Builder

The Delete and Update Builder WhereEquals method has been replaced with Where().IsEqualTo() to align it with the Select Builder

MicroLite.Extensions.Mvc

Method signature needs to change from:

public ActionResult MethodName(args)

to

public async Task<ActionResult> MethodName(args)

MicroLite.Extensions.WebApi

Method signature needs to change from:

public HttpResponseMessage Get(int id)

to

public Task<HttpResponseMessage> Get(int id)

example:

public Task<HttpResponseMessage> Get(int id)
{
    return this.GetEntityResponseAsync(id);
}

MicroLite Extension Release Candidates

A release candidate for all the MicroLite extensions has been released built against MicroLite 6.0-rc. As with the MicroLite 6.0-rc, these are still to be considered pre-release so don’t roll them into production just yet!

When the final build of each extension is released along side MicroLite 6.0, I will publish full release notes and an upgrade guide but here’s a couple of pointers if you want to try out the release candidates:

Mvc and WebApi extension

The .NET 4.5 build of both the extensions now use the Async version of the Session API added in MicroLite 6.0, if you use the .NET 4.5 build you will need to use IAsyncSession instead of ISession and IAsyncReadOnlySession instead of IReadOnlySession.

WebApi extension

The method signature for the MicroLiteApiController<T> and the MicroLiteODataApiController<T> helpers has changed from:

protected virtual HttpResponseMessage ...

to

protected virtual Task<HttpResponseMessage> ...

So for the Get method you would need to update from:

public HttpResponseMessage Get(int id)
{
    return this.GetEntityResponse(id);
}

to

public Task<HttpResponseMessage> Get(int id)
{
    return this.GetEntityResponse(id);
}

DbEncryptedString

The DbEncryptedString class has now moved to a new package MicroLite.Extensions.Cryptography.