虚拟财产与私人集
我正在尝试在 MVC 项目中使用 Fluent nhibernate...我对 nhibernate 和 Fluent 非常陌生...似乎实体应该具有虚拟的属性,并且该集合对于 ID 应该是私有的...我使用 vb 语言...所以尝试使用可重写...它给出了一个错误...
Public Overridable Property DesignId() As Integer
Get
End Get
Private Set(ByVal value As Integer)
End Set
End Property
它说属性不能被重写,因为它有一个私有访问器...不知道如何进行...网上的所有教程都是c# ...我的客户特别是VB...提前致谢...
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
特别是对于 VB,如果您将 setter 设置为受保护,则应该避免出现错误(因为受保护允许您覆盖该设置)。
Specifically to VB, if you make the setter protected, that should avoid giving you the error (since Protected allows you to override the setting).
使用受保护的而不是私有的。如果您的设计可以的话,使用 Public 也可以 - Set 不必是 Private,这就是好的设计。
私有错误是 VB 限制,这在 C# 中有效。 VB 需要重写 getter 和 setter,而 C# 则不需要。
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.
如何使 setter 受到保护,以便重写的类可以看到它......
即:
How about making the setter protected, so that the overriding classes can see it...
I.e.: