2010-07-29 7 views
0

과 함께 유창 NHibernate의 속성을 무시 VB.Net 및 (유창한) NHibernate에 대한 정보가 거의 없기 때문에이 질문을 다른 개발자들이 더 많은 정보를 찾고 있음을 알기로 결정했습니다. .VB.Net (2.0)

내가 고심해야했던 것 중 하나는 NHibernate에서 속성을 무시하는 방법이었습니다.

인터페이스 클래스 (ILists)를 직렬화 할 수없는 Webserivce를 사용했기 때문에 속성을 무시해야하는 이유가있었습니다. 어느 NHibernate와 많이 사용됩니다.

그래서 우리는 NHibernate에서 일부 속성을 무시하고 이러한 속성을 IList 객체를 Webservice에서 사용할 수있는 List 객체로 변환해야했습니다.

우리는 VB.Net이 C# 코드에서 좋은 번역을 찾을 수 없습니다 : 문제를 해결하기 위해 다른 솔루션을

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

또는

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

을 발견 (자체 제작 참조 대답)

답변

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)