流利的NHibernate:混合自动映射和手动映射 [英] Fluent NHibernate: Mixing Automapping and manual mapping

查看:105
本文介绍了流利的NHibernate:混合自动映射和手动映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果使用Fluent NHibernate,是否可以自动映射大多数类,但指定应使用常规fluent API映射几个特定类,而不是自动映射?如果是这样,谁能指出我一些示例代码来说明如何做到这一点?

If using Fluent NHibernate, is it possible to automap most classes, but specify that a couple of particular classes should be mapped using the regular fluent API rather than being automapped? And if so, can anyone point me to some sample code that shows how to do it?

谢谢!

推荐答案

可能容易混淆映射配置:

It is possible and easy to mix-up mapping configurations:

var cfg = Fluently.Configure()
    .Database(configurer)
    .Mappings(map =>
                  {
                      // Automapping
                      map.AutoMappings.Add(AutoMap.Assemblies(Assembly.GetExecutingAssembly())
                                             .Where(type => type == typeof(Domain.Market.Share))
                                             .Where(type => type == typeof(Domain.HR.Employee)));

                      // Fluent mappings
                      map.FluentMappings.AddFromAssemblyOf<Domain.Client.Macys>();
                  });

祝你好运. ;-)

这篇关于流利的NHibernate:混合自动映射和手动映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆