功能NHibernate:被映射的预防类(Fluent NHibernate: Prevent cl

2019-09-17 01:35发布

我相信这是小菜一碟,但使用谷歌,我不能找到它。 我需要从映射排除单个类。 我现在的配置是:

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();

工作良好,那么远,但我有一些类我不想映射。 有像什么:

伪代码:

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();

Answer 1:

我会尝试

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


文章来源: Fluent NHibernate: Prevent class from being mapped