public TutorialDbContext OpenDatabase() { // データベースを作成したり、データベースに接続したりするには、DbConfig を使用します。 // 以下にその手順を説明します。 // To connect or create a database, use DbConfig. Like this: var dbConfig = new DbConfig <TutorialDbContext>(); // 一意性制約が使用できます。 // メモ: 実際にはハッシュ表の索引が作られますが、それを使用する手段は未実装です。 // Unique constraints are available. // Note: Actually a hashtable index is created for each unique contraints, you can't use it yet. dbConfig.Add <Person>(UniqueIndex.Of <Person>(p => p.Name)); // そして、OpenMemory メソッドを呼び出して、インメモリーのデータベースを生成します。 // Then invoke OpenMemory to create an in-memory database. return(dbConfig.OpenMemory("sample_db")); // ディスクベースのデータベースに対しては、代わりに OpenDirectory メソッドを使用してください。 // これは OpenMemory とは異なり、既存のデータベースを開くことができます。 // 重要: データベースのディレクトリーがすでに存在し、しかしモデルクラスが異なっている場合、 // すべてのテーブルが Drop され、改めて新しいテーブルが作られます。 // Use OpenDirectory for disk-based one instead. // Unlike OpenMemory, OpenDirectory can open an exsiting database. // Note: If the database directory exists but model classes have changed, // all tables are dropped and new tables are created again. //return dbConfig.OpenDirectory(new System.IO.DirectoryInfo(@"path/to/directory")); }