2012-01-13 21 views
2

如何從nhibernate配置中導出hibernate.cfg.xml。我在代碼中配置了nhibernate而不是導入cfg.xml。我現在需要將cfg和映射xml文件導出到其他nhibernate工具中。我找到了一種導出mapping.xml的方法,但未能找到導出cfg的方法。nhibernate在通過代碼配置時導出hibernate.cfg.xml

NHibernate 3.2

回答

0

我懷疑有一個簡單的方法如何做到這一點。 NHibernate.Cfg.Configuration不包含任何對符合nhibernate-configuration-2.2 xml模式的NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration類的引用。您可以嘗試從您自己的Configuration實例中推斷出HibernateConfiguration類的所有屬性。

NHibernate.Cfg.Configuration本身是可序列化的,但它被序列化爲完全不同的模式。

IMO回退到傳統的cfg.xml文件將是更容易的解決方案。