代码之家  ›  专栏  ›  技术社区  ›  Matt

你能混合使用Fluent NHibernate和传统的hbm.xml吗

  •  7
  • Matt  · 技术社区  · 17 年前

    我们已经在hbm.xml中完成了一些映射,我不希望以编程方式映射这些映射。在我们有时间偿还债务之前,您能将它们混合在同一个sessionfactory中吗?

    1 回复  |  直到 17 年前
        1
  •  8
  •   Jelle    17 年前

    我的SessionFactory结构如下所示:

            _configuration = new Configuration();
            _configuration.SetProperties(properties);
    
            // hbm files
            _configuration.AddAssembly(typeof(ISurveyTask).Assembly);
    

            var persistenceModel = new PersistenceModel(...)
    
            // fluent mappings
            persistenceModel.addMappingsFromAssembly(typeof(ISurveyTask).Assembly);
            persistenceModel.Configure(_configuration);
    

    享受:-)