Knight Data Access Layer
Manually Creating A Session
Basic Tasks C# > Creating A Session > Manually Creating A Session

Manually Creating A Session

Below is an example of creating a data access layer object without using the session factory.

 

//Build the connection string

SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();

string databasePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyDatabase.db");

builder.DataSource = databasePath;

 

//Setup the provider

SqLiteProvider provider = new SqLiteProvider();

provider.ConnectionString = builder.ConnectionString;

 

//Manually instantiate a session

DataHelper db = new DataHelper(provider);

 

Set Licensing

The default is a 30 day trial mode.  Skip this step if you are doing a trial.  After you receive your user name and license key during the purchase process, set it.

db.UserName = "John Smith 1234";

db.LicenseKey = "a9sdkw==";