Framework configuration is managed by a LightSpeedContext object, either programmatically or through a standard .NET configuration file.

Programmatic Configuration

To configure LightSpeed programatically, simply set the set the appropriate properties on LightSpeedContext.

CopyConfiguring LightSpeed in code
1var context = new LightSpeedContext();
2
3context.ConnectionString = "server=localhost; database=MyFirstProject; Integrated Security=SSPI;";
4context.DataProvider = DataProvider.SqlServer2005;
5context.IdentityMethod = IdentityMethod.IdentityColumn;

.NET XML Configuration File

An example of a standard file-based configuration is shown below.

CopyConfiguring through App.config
 1<?xml version="1.0" encoding="utf-8" ?>
 2
 3<configuration>
 4
 5  <configSections>
 6    <section name="lightSpeedContexts" 
 7             type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" />
 8  </configSections>
 9
10  <lightSpeedContexts default="Test">
11
12    <add name="Test"
13         connectionStringName="Test"
14         dataProvider="Sqlite3"
15         identityMethod="KeyTable"
16         loggerClass="Mindscape.LightSpeed.Tests.CustomLogger, Mindscape.LightSpeed.Tests.Common"
17         cacheClass="Mindscape.LightSpeed.Caching.DefaultCache, Mindscape.LightSpeed"
18         pluralizeTableNames="true"
19         schema="public"
20         namingStrategyClass="Mindscape.LightSpeed.Tests.CustomNamingStrategy, Mindscape.LightSpeed.Tests.Common"
21         displayNamingStrategyClass="Mindscape.LightSpeed.Tests.CustomDisplayNamingStrategy, Mindscape.LightSpeed.Tests.Common"
22         searchEngineClass="Mindscape.LightSpeed.Search.LuceneSearchEngine"
23         searchEngineFileLocation="c:\foo\bar\baz"
24         cascadeDeletes="false"/>
25
26    <add name="SQLite"
27         connectionStringName="SQLite"
28         dataProvider="SQLite3"
29         identityMethod="KeyTable"
30         pluralizeTableNames="true"         
31         cascadeDeletes="false" />
32
33    <add name="Postgres"
34         connectionStringName="Postgres"
35         dataProvider="PostgreSql8"
36         identityMethod="KeyTable"
37         pluralizeTableNames="true"
38         cacheClass="Mindscape.LightSpeed.Caching.DefaultCache, Mindscape.LightSpeed"
39         namingStrategyClass="Mindscape.LightSpeed.Tests.PostgresNamingStrategy, Mindscape.LightSpeed.Tests.Common"
40         quoteIdentifiers="true" />
41
42    <add name="Utc"
43         connectionStringName="SQLite"
44         dataProvider="SQLite3"
45         identityMethod="KeyTable"
46         pluralizeTableNames="true"
47         autoTimestamps="Utc"
48         commandTimeout="120"
49         />
50
51  </lightSpeedContexts>
52
53  <connectionStrings>
54    <add name="Test"     connectionString="My Connection String" />
55    <add name="SQLite"   connectionString="Data Source=..\..\..\Schema\SQLite3\ORMapper.db3" />
56    <add name="Postgres" connectionString="Server=ORMapper;Database=ORMapper;User Id=postgres;Password=Password1" />
57  </connectionStrings>
58
59</configuration>

To load a particular configuration into a given LightSpeedContext, pass the name of the configuration section to the LightSpeedContext constructor:

CopyLoad configuration from file
1var context = new LightSpeedContext("SQLite");

Configuration Settings

LightSpeed supports the following configuration options. These may be set programatically on LightSpeedContext or within a standard .NET configuration file.

Connection String (connectionString)

A standard ADO.NET connection string. This configuration attribute is required.

Data Provider (dataProvider)

The name of a LightSpeed supported data provider. Supported providers are list in the following table.

Provider Name Description
SqlServer2000 Microsoft SQL Server 2000 using System.Data provider.
SqlServer2005 Microsoft SQL Server 2005 using System.Data provider.
SqlServer2008 Microsoft SQL Server 2008 using System.Data provider.
MySql5 MySQL 5 database using MySql.Data provider.
PostgreSql8 PostgreSQL 8 database through Npgsql provider.
SQLite3 SQLite 3 database through System.Data.SQLite provider.
Oracle9 Oracle 9 (or higher) database through System.Data.OracleClient provider.
Oracle9Odp Oracle 9 (or higher) database through Oracle.DataAccess provider.
VistaDB3 VistaDB 3 database through VistaDB.NET20 provider.
VistaDB4 VistaDB 4 database through VistaDB.4 provider.
Firebird2 Firebird 2 database through FirebirdSql.Data.FirebirdClient provider
SqlServerCE SQL Server Compact 3.5 through System.Data provider.
DB2 DB2 9.5 through IBM.DB2 provider.
AmazonSimpleDB Amazon SimpleDB cloud database or compatible.

Identity Generation Method (identityMethod)

The method used to obtain new identity values (e.g. Guid)

Logger Class (loggerClass)

The name of a type implementing the Mindscape.LightSpeed.ILogger contract. See Logging.

Pluralization (pluralizeTableNames)

A boolean value indicating whether LightSpeed infers table names as plural.

Update Batch Size (updateBatchSize)

LightSpeed batches database updates to reduce network round-trips. This attribute determines the maximum number of DML statements per batch.

Identifier Quoting (quoteIdentifiers)

Whether identifiers are quoted in generated SQL.

Identify Block Size (identityBlockSize)

Determines the number of identity values generated per allocation. Applies to the IdentityMethod.KeyTable identity generation strategy.

Cache Class (cacheClass)

The full assembly qualified name of a type that implements the ICache interface. Use this to enable the second-level cache.

Naming Strategy Class (namingStrategyClass)

The full assembly qualified name of a type that implements the INamingStrategy interface. Use this extension point if you want to customize how LightSpeed resolves database names.

Detect Property Names (detectPropertyNames)

By default, LightSpeed automatically detects the property name to be used when an Entity raises a Entity.PropertyChanged event. Set this option to false to suppress automatic detection. If you set this option to false, and you use the LightSpeed Entity API to set properties, you must use the overload of Entity.Set which specifies the property name explicitly.

Search Engine Class (searchEngineClass)

The full assembly qualified name of the type that implements the ISearchEngine interface. Use this extension point if you want to create your own search engine implimentation otherwise use ‘Mindscape.LightSpeed.Search.LuceneSearchEngine’ to use the built in Lucene.Net search provider.

Search Engine File Location (searchEngineFileLocation)

The location on the filesystem where the search index should be stored. The provided search engine stores the search index on the filesystem and is therefore database independent.

Auto Timestamps Model (autoTimestamps)

The method used to generate timestamps for the CreatedOn, UpdatedOn and DeletedOn fields. Options are Local and Utc. (Custom timestamp strategies must be specified in code.) If omitted, the Local method is used.

Command Timeout (commandTimeout)

The database timeout in seconds. If omitted, the default database timeout is used.