Windowsフォームプロジェクトの作成

データを操作するクライアントとしてWindowsフォームプロジェクトを作成します。ここではLs.UIという名前を付けて、以下の参照設定をします。

・Ls.Domainプロジェクト
・Mindscape.LightSpeed.dll(C:\Program Files\Mindscape\LightSpeed 2.1\Bin)
・Mindscape.LightSpeed.Linq.dll(LINQを使う場合)
・データベースのDLL(サードベンダーのDBを使う場合)

Windowsフォームプロジェクトの作成

App.Configの記述

プロジェクトを右クリックし[追加]-[新しい項目]をクリックし、[アプリケーション構成ファイル]を追加します。作成されたApp.configファイルにLightSpeed用の設定を記述します。

アプリケーション構成ファイルの設定(App.config)


<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<!-- LightSpeed用のセクションを設定 --> <configSections> <section name="lightSpeedContexts" type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" /> </configSections>

<!-- データベースの接続文字列 --> <connectionStrings> <add name="LsSql2005" connectionString="server=.\SQLEXPRESS;database=LsDemo; Integrated Security=SSPI;"/> </connectionStrings>

<!-- LightSpeedの設定(LightSpeedContextの設定) --> <lightSpeedContexts> <add name="SqlServer" connectionStringName="LsSql2005" dataProvider="SqlServer2005" identityMethod="KeyTable" pluralizeTableNames="false"/> </lightSpeedContexts>

</configuration>

LightSpeedの設定

アプリケーション構成ファイルには、次のような項目を設定できます。

LightSpeedの主要な設定項目

設定名 説明
name 設定の名称
cacheClass ICacheを実装するキャッシュクラス名
connectionStringName 接続文字列の名前
dataProvider データベースプロバイダ(SqlServer2005、MySql5、PostgreSql8、SQLite3、Oracle9、Oracle9Odp、VistaDB3、Firebird2、SqlServerCE)
identityMethod アイデンティの生成方法(KeyTable、Guid、Sequence、IdentityColumn、GuidComb)
loggerClass ILoggerを実装するログクラス名
puralizeTableNames テーブル名を複数形にするか

他にも設定できる項目がありますので、詳細については、ドキュメントのConfigurationのページを参考にすると良いでしょう。