AutoMapping Custom Collections with FluentNHibernate

瘦欲@ 提交于 2019-12-11 00:09:31

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/2899576/automapping-custom-collections-with-fluentnhibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!