使用VB.Net(2.0)忽略Fluent NHibernate中的属性

使用VB.Net(2.0)忽略Fluent NHibernate中的属性,vb.net,nhibernate,fluent-nhibernate,convention,Vb.net,Nhibernate,Fluent Nhibernate,Convention,因为关于VB.Net和Fluent NHibernate的信息太少了,我决定把这个问题写给所有其他正在寻找更多信息的开发人员 我不得不努力解决的一件事是如何忽略NHibernate中的属性 我不得不忽略属性的原因是因为我们使用的Webserivce无法序列化接口类ILists。与NHibernate一起使用较多 因此,我们不得不忽略NHibernate中的一些属性,让这些属性将IList对象转换为可以在Webservice中使用的列表对象 我们找不到此C代码到VB.Net的任何好的翻译: .Ov

因为关于VB.Net和Fluent NHibernate的信息太少了,我决定把这个问题写给所有其他正在寻找更多信息的开发人员

我不得不努力解决的一件事是如何忽略NHibernate中的属性

我不得不忽略属性的原因是因为我们使用的Webserivce无法序列化接口类ILists。与NHibernate一起使用较多

因此,我们不得不忽略NHibernate中的一些属性,让这些属性将IList对象转换为可以在Webservice中使用的列表对象

我们找不到此C代码到VB.Net的任何好的翻译:

.Override<Shelf>(map =>  
{  
  map.IgnoreProperty(x => x.YourProperty);
});

并找到了解决问题的不同解决方案参见自制答案制作一个实现DefaultAutomappingConfiguration的新类

Imports FluentNHibernate.Automapping

Public Class AutomapperConvention
    Inherits DefaultAutomappingConfiguration

    Public Overrides Function ShouldMap(ByVal member As FluentNHibernate.Member) As Boolean
        'When the the mapper finds a List object it ignores the mapping you can make your own choices here'
        If (member.PropertyType.IsGenericType AndAlso Not (member.PropertyType.IsInterface)) Then
            Return False
        Else
            Return MyBase.ShouldMap(member)
        End If
    End Function

End Class
在此处添加自动映射约定:

'Custom automapping to make the automapper find the correct id's (entityname + "Id")
Dim mappingConfig As New AutomapperConvention()
Dim model As New FluentNHibernate.Automapping.AutoPersistenceModel(mappingConfig)
'Custom automapping to make the automapper find the correct id's (entityname + "Id")
Dim mappingConfig As New AutomapperConvention()
Dim model As New FluentNHibernate.Automapping.AutoPersistenceModel(mappingConfig)