-
Notifications
You must be signed in to change notification settings - Fork 302
Getting started
kradcliffe edited this page Jan 22, 2012
·
4 revisions
To open a SQL Server database:
var db = Database.OpenConnection("data source=.;initial catalog=Xyz;etc");
To open a SQL Server Compact Edition 4.0 database:
var db = Database.OpenFile("mydb.sdf");
You can specify a database for Simple.Data in the connectionStrings section of the config file:
<connectionStrings>
<add name="Simple.Data.Properties.Settings.DefaultConnectionString"
connectionString="data source=.;initial catalog=Simple;integrated security=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
Then you can open this database with the parameterless Open method:
var db = Database.Open();
or use a single instance provided as default:
Database.Default.Users.FindById(1);
Simple.Data holds no open connections to the database, so you can keep the db object returned from the Open methods hanging around without worrying.