使用FluentNHibernate自动映射自定义集合 [英] AutoMapping Custom Collections with FluentNHibernate

查看:221
本文介绍了使用FluentNHibernate自动映射自定义集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在改进一个非常大的应用程序使用NHibernate作为它的数据访问策略。一切都很顺利与自动映射。幸运的是,当构建域层时,我们使用了一个代码生成器。我现在遇到的主要问题是,每个集合都隐藏在一个自定义类从List<>派生。例如

I am retrofitting a very large application to use NHibernate as it's data access strategy. Everything is going well with AutoMapping. Luckily when the domain layer was built, we used a code generator. The main issue that I am running into now is that every collection is hidden behind a custom class that derives from List<>. For example

public class League
{
   public OwnerList owners {get;set;}
}
public class OwnerList : AppList<Owner>  { }
public class AppList<T> : List<T>  { }

我必须写什么样的约定才能完成这项工作?

What kind of Convention do I have to write to get this done?

推荐答案

我不认为你将能够实现这个约定。您必须创建自动映射替换,然后执行以下操作:

I don't think you're going to be able to achieve this with a convention. You will have to create an auto mapping override and then do the following:

mapping.HasMany(l => a.owners).CollectionType<OwnerList>();

这篇关于使用FluentNHibernate自动映射自定义集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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