0

VB.Netと(Fluent)NHibernateに関する情報がほとんど見つからないため、より多くの情報を探している他のすべての開発者にこの質問を書くことにしました。

私が苦労しなければならなかったことの1つは、NHibernateのプロパティを無視する方法でした。

プロパティを無視しなければならなかった理由は、インターフェイスクラス(ILists)をシリアル化できないWebサービスを使用したためです。これはNHibernateでよく使用されます。

そのため、NHibernateの一部のプロパティを無視し、それらのプロパティでIListオブジェクトをWebサービスで使用できるListオブジェクトに変換する必要がありました。

このC#コードからVB.Netへの適切な翻訳は見つかりませんでした。

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

また

.OverrideAll(map =>  
{  
  map.IgnoreProperty("YourProperty");
});

そして、問題を解決するための別の解決策を見つけました(自作の答えを参照してください)

4

1 に答える 1

0

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

ここに AutomapperConvention を追加します。

'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)
于 2010-07-29T13:00:41.310 に答える