views:

41

answers:

4

I am trying to use fluent nhibernate in a MVC project... i am very new to nhibernate and fluent... It seems the entities should have properties that are virtual and the set should be private for IDs... i use vb language...so tried using overrideable...it gives an error...

Public Overridable Property DesignId() As Integer
    Get

    End Get
    Private Set(ByVal value As Integer)

    End Set
End Property

it says property cannot be overrideable because it has a private accessor...have no idea how to go about...all tutorials in the net are in c#... my client specifically in vb....thanks in advance...

+1  A: 

How about making the setter protected, so that the overriding classes can see it...

I.e.:

Private _designId as Integer
Public Overridable Property DesignId() As Integer
    Get
        Return _designId
    End Get
    Protected Set(ByVal value As Integer)
        _designId = value
    End Set
End Property
Rowland Shaw
A: 

Hello,

Specifically to VB, if you make the setter protected, that should avoid giving you the error (since Protected allows you to override the setting).

Brian
A: 

Use Protected instead of Private. It's OK to use Public, too, if that OK with your design - Set is not necessary to be Private, that's just good design.

The Private error is VB limitation, this works in C#. VB requires to override both getter and setter, while C# does not.

queen3
A: 

hey thanks guys...changing the setter to protected did the trick..!

ZX12R