私はここでちょっと迷っています。
調べてみると、SQLite DBファイルを作成するためのSQLite GUIツールがいくつかあるようです。一方、NHibernate には SQLite のメモリ内構成が付属していることにも気付きました
return Fluently.Configure().Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyEntityMap>()).Database(SQLiteConfiguration.Standard.InMemory().ShowSql()).BuildSessionFactory();
このような設定では、DB ファイルを使用するオプションはありません。では、NHibernate を使用してすべての CRUD 操作を実行する前に、まずすべてのテーブル構造を作成し、インメモリ データベースにレコードを挿入するにはどうすればよいでしょうか?
ありがとう
編集 1 -- マッピング クラスとセッション クラスを含める My エンティティ ベース クラス
Public MustInherit Class SingleKeyEntity(Of TId)
Public Overridable Property Id() As TId
Get
Return m_Id
End Get
Set(value As TId)
m_Id = value
End Set
End Property
End Class
私のエンティティクラス
Public Class Subscription
Inherits SingleKeyEntity(Of System.Nullable(Of Integer))
Private m_Subscriber As String
Public Overridable Property Subscriber() As String
Get
Return m_Subscriber
End Get
Set(value As String)
m_Subscriber = value
End Set
End Property
Private m_Format As String
Public Overridable Property Format() As String
Get
Return m_Format
End Get
Set(value As String)
m_Format = value
End Set
End Property
クラス終了
私のマッピングクラス
Public Class SubscriptionMap
Inherits ClassMap(Of Subscription)
Public Sub New()
Table("SUBSCRIPTIONS")
Id(Function(x) x.Id, "ID").GeneratedBy.Identity()
Map(Function(x) x.Subscriber, "SUBSCRIBER").[Not].Nullable()
Map(Function(x) x.Format, "DISTRIBUTION_FORMAT").[Not].Nullable()
' more properties omitted
End Sub
End Class
そして私のセッション構成
Return Fluently.Configure() _
.Mappings(Function(m) m.FluentMappings.AddFromAssemblyOf(Of SubscriptionMap)()) _
.Database(SQLiteConfiguration.Standard.InMemory().ShowSql()) _
.ExposeConfiguration(Sub(x As NHibernate.Cfg.Configuration)
Dim export As SchemaExport = New SchemaExport(x)
'export.Execute(False, True, False)
export.Create(False, True)
End Sub) _
.BuildSessionFactory()