流畅的NHibernate:防止类被映射

时间:2009-06-25 20:59:42

标签: nhibernate fluent-nhibernate fluent

我确信这是小菜一碟,但我无法使用谷歌找到它。 我需要从映射中排除一个类。我目前的配置是:

return Fluently.Configure()
      .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c =>
                c.Is(@"Data Source=PC\SQLEXPRESS;......")))
            .Mappings(m =>
                m.AutoMappings.Add(
                AutoPersistenceModel.MapEntitiesFromAssemblyOf<Person2>()
                        .Where(t => t.Namespace == "ExampleData.HumansTest")
                        .UseOverridesFromAssemblyOf<PersonMappingOverrides>()
                        .ConventionDiscovery.AddFromAssemblyOf<PersonMappingOverrides>()
                        )
                     ).BuildConfiguration();

效果很好,到目前为止...... 但我有一些我不想映射的课程。有没有像:

PSEUDO CODE:

return Fluently.Configure()
            .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c =>
                c.Is(@".......")))
            .Mappings(m =>
                m.AutoMappings.Add(
                AutoPersistenceModel.MapEntitiesFromAssemblyOf<Person2>()
                        .Where(t => t.Namespace == "ExampleData.HumansTest")
                        .DO_NOT_MAP_CLASS<UnfinishedClass>
                        .UseOverridesFromAssemblyOf<PersonMappingOverrides>()
                        .ConventionDiscovery.AddFromAssemblyOf<PersonMappingOverrides>()
                        )
                     ).BuildConfiguration();

1 个答案:

答案 0 :(得分:7)

我试试

...
.Where(t => t.Namespace == "ExampleData.HumansTest"
           && t != typeof(UnfinishedClass))
...