2014-03-04 51 views
0

我想爲我們的FluentNhibernate ORM單元測試設置一個SQLite測試數據庫。「沒有空間方言配置」錯誤爲流利。配置

經過與幾何元素的工作麻煩我做了下面的一篇博客文章中一些調整:http://blogs.microsoft.co.il/dorony/2010/05/26/easy-testing-of-nhibernatespatial-code/

我使用的是最新的NHibernate + FluentNhibernate與NHibernate.Spatial起價github上(https://github.com/suryapratap/Nhibernate.Spatial)一起 - 與破碎的Oracle位被刪除。

我有一個幾何類型一類我已經改變到:

public virtual IGeometry DelytaGrans { get; private set; } 

我與

Map(x => x.DelytaGrans).CustomType(typeof(GeometryType)); 

映射它我已經創建了一個SQLiteGeometryTypeConvention和SQLiteGeometryType(如在所描述的博客)在我的測試項目中打電話流利配置如下:

var sessionFactory= Fluently.Configure() 
        .Database(SQLiteConfiguration.Standard.InMemory)      
        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Delyta>() 
            .Conventions.Setup(x => x.Add(AutoImport.Never())) 
            .Conventions.Add(new SQLiteGeometryTypeConvention()) 
            .Conventions.Add(FluentNHibernate.Conventions.Helpers.DefaultLazy.Never())       
         ).BuildSessionFactory(); 

它返回一個錯誤:

----> NHibernate.MappingException : The constructor being called throws an exception. 
----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. 
----> NHibernate.MappingException : A GeometryType column has been declared, but there is no spatial dialect configured 

我沒有什麼運氣來找出這裏有什麼問題。我看過一些例子,其中人們在配置文件中引入.Dialect,但這似乎與SqlServer相似,而我對SQLiteConfiguration的看法完全沒有。

回答

0

我所做的更改(對博客中給出的代碼)是刪除自定義類型。

給予的

Map(x => x.DelytaGrans); 

的映射,現在工作得很好。