Fluent NHibernate: Prevent class from being mapped

2019-05-06 17:20发布

I am sure it is a piece of cake, but I can't find it using google. I need to EXCLUDE a single class from mapping. My current configuration is:

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

Works nice, so far... But I have some classes I don't want to map. Is there anything like:

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条回答
聊天终结者
2楼-- · 2019-05-06 17:53

I'd try

...
.Where(t => t.Namespace == "ExampleData.HumansTest"
           && t != typeof(UnfinishedClass))
...
查看更多
登录 后发表回答