ServiceStack/ServiceStack.OrmLite — pull request #134 by AkosLukacs (2013-01-15 17:06:49+00:00)
Title: Miniprofiler + multiple db types == confused DialectProvider

Found another edge case:

The OrmLiteConnections created by OrmLiteConnectionFactory are wrapped by the factory's ConnectionFilter, if it's present. Therefore the return type from the factory isn't a OrmLiteConnection, and read/write extensions can't access the connection's DialectProvider.

This is a problem, when using multiple database types simultaneously, and using Miniprofiler at the same time. The last connection's dialect stays in the static DialectProvider attribute, therefore OrmLite won't be able to generate the right SQL for the rest of the connections.

Here is a repro: https://github.com/AkosLukacs/OrmLite_MiniProfiler_multiple_db_types
Just launch it, and go to /hello.
Use the official OrmLite dll to make it fail, and the dll from the "@modifiedDlls" folder.

This commit solves this problem by wrapping the OrmLiteConnection's dbConnection property, not the OrmLiteConnection. Therefore the DialecProvider can be extracted from the OrmLiteConnection even when using Miniprofiler.