I'm tired of watching tutorials and explanations of how to implement SQLite in Enterprise Library which did not reach anything or official articles worked, configurations, nothing about for a single example of such could be put to work, route until reaching the version 6 it appears completely closed the support! I have worked on a fully functional example of the necessary provider to make this work!
It's true that SQLite not support stored procedures, but this is not an inconvenience, since it can create queries that simulate stored procedures, do these simulations are not slow, think there is no longer the problem of SQL Server, no connections, everything works local, direct, and SQLite can create custom functions to avoid the problem.
This provider and adapter not only creates the necessary tables to work, makes the inserts as you would the stored procedures, the created tables and relations is fully compatible with the work of the original Trace Listener.
Using the code
Simply in your App.config / Web.config attach the adapters, the second isn't necessary because we not use EL6, the intention is use in the future, for example with Entity Framework
<remove invariant="System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EL6" />
<add name="SQLite Data Provider EL6" invariant="System.Data.SQLite.EL6" description="EnterPrise Library 6 Data Provider for SQLite" type="EntLibContrib.Data.SQLite.SQLiteDatabase, EntLibContrib.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
And this in your Entlib.config
Microsoft.Practices.EnterpriseLibrary.Data, Version=126.96.36.199, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
EntLibContrib.Data.SQLite" name="System.Data.SQLite.EL6" />
<add name="Service_Dflt" providerName="System.Data.SQLite.EL6"
connectionString="Data Source=|DataDirectory|ELSqLiteLog@|CurrentDate|.db;Version=3;" />
<add name="Database Trace Listener"
formatter="Text Formatter" />
Now you can use the "Database Trace Listener" in your
Points of Interest
Ok Ok, this is only how can you configure the Adapter and the TraceListener, but what about it, where is the magic? all the magic is in
FormattedDatabaseTraceListener, you can see the code inside of the attached file.
DatabaseTraceListener, is the modified version of the original of the MSSQL, the table creation are inside of code (scripts), the queries than emulates the stored procedures are too inside, because the difference of the original
FormattedDatabaseTraceListener only has 2 parameter less (
addCategoryStoredProcName) and the calls, the result is a equal work than the original
object has a little interesting present for you "
" Environment Variable, can you use in the
to make a Log file each day!
- 1.1 Now supports Visual Studio 2010 Framework 4 with Enterprise Library 5.
- 1.0 Initial public release of the provider, adapter, and example.