好吧,我有一個數據庫,但沒有表格。我有一些實體類。我試圖設置Fluent NH來自動模式導出自動映射。流利的NHibernate - 自動模式構建
首先,這是可能的,對吧?
其次,如果是這樣,我在做什麼錯在這裏:
private ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(c => c.Is(@"Data Source=foo;Initial Catalog=bar;Integrated Security=True")))
.Mappings(m => m.AutoMappings.Add(AutoPersistenceModel.MapEntitiesFromAssemblyOf<Employee>()
.Where(t => t.Namespace.Contains("Entities"))))
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
}
private void BuildSchema(Configuration cfg)
{
new SchemaExport(cfg).Create(false, true);
}
我得到一個錯誤「對象引用未設置到對象的實例」上面的「凡」行。如果我取出.Where條件,則會出現錯誤「對於ContainsGenericParameters爲true的類型或方法,無法對後期操作執行操作。」
編輯:
一些額外的信息:我改變了。哪裏聲明專門概述了包括實體。即「.Where(t => t.Name.Contains(」Employee「)」等等)當我這樣做時,我得到了一個關於缺少依賴關係的錯誤(NHibernate.ByteCode.Castle)。當我解決這個問題時,它工作正常我還是不明白爲什麼這工作雖然。
那麼爲什麼改變我的.Where子句讓我知道那一點? – 2009-08-05 01:04:58