I am a C # programmer, limited to writing VB.NET code.
When learning NHibernate for my current client, I came across FluentNHibernate, which I find really attractive.
But now I'm wondering how to "translate" this C # code to map components to VB.NET code:
Component(x => x.Address, m => { m.Map(x => x.Number); m.Map(x => x.Street); m.Map(x => x.PostCode); });
I know from here:
Component(Of Client)(Function(c) c.Address, ...)
what I missed is how to continue the brackets in VB.NET, since there are no keywords to start, etc.
EDIT 1: Following Mr. Jared Par's instructions, I realized that his solution might work. If we take the time to read his answer, we may notice that we both do not know that MType is in his decision. I could find out that MType:
FluentNHibernate.Mapping.ComponentPart(Of TComponent)
So TComponent, in my opinion, is an anonymous type, which I will use as a parameter. From this perspective, since I want to map the properties of my Address object, replacing the TComponent in my help method signature does not seem to work.
Private Sub MapAdresseHelper(Of Adresse)(ByVal a As FluentNHibernate.Mapping.ComponentPart(Of Adresse)) a.Map(Function(m) m.Number) a.Map(Function(m) m.Street).Length(50) a.Map(Function(m) m.PostCode).Length(10) End Sub
The error I get is that my Address class does not have, for example, a Street property element. He sees my type of address, he recognizes it, but somehow he seems to be a buggy. I think that VBNET is poorly designed for lambda expressions and less developed than C # (Sorry, a little disappointment due to the limitations of working with it and the inability to do things is VERY easy to do in C #.)