Use
You use MicroDal in a using-statement (unless You want to take advantage of the static Current property).
using (var ses = new DataSession("myConnectionName"))
{
var person = ses.FetchOne<PersonDTO>("SELECT * FROM Persons WHERE id=@id", 123);
TextBox1.Text = person.Firstname + " " + person.Lastname;
}
Setup ASP.NET
You can either use MicroDal with an instance of the DataSession object, or with the static Current property. To use the static property, You have to configure the connectionstring in web.config, and add a appSettings key named: MicroDalConnectionName and with the value set to the name of the connection You wish to use.
The advantage of using the static property is that You have acces to the same DataSession in the whole Request lifetime - saving connections.
Tracing
MicroDal uses the .NET TraceSource object as logging/tracing mecanism.
To enable insert the following section in your config file:
<system.diagnostics>
<sources>
<source name="MicroDal" switchType="System.Diagnostics.SourceSwitch" switchValue="Information">
<listeners>
<add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</listeners>
</source>
</sources>
</system.diagnostics>
Learn more
Getting started Use a dynamic DTOUnittesting Test mockExecuting Stored Procedures