[英]How to indicate that an Entity Framework object is implementing an interface?
OK, I have to begin saying that I'm working with Visual Basic. 好的,我必须开始说我正在使用Visual Basic。 The problem is that I have a Entity Framework object and I want to indicate that this object implements a interface, for example:
问题是我有一个Entity Framework对象,并且想指出该对象实现了一个接口,例如:
Public Interface ICatalog
Property created_at() As Date
Property id() As Long
End Interface
Those properties are allready in the object. 这些属性已在对象中就绪。 In c# I've done this just by declaring a partial class of the object and indicates that implements that interface, but in basic is not working, I supouse that is because of the language sintaxis used to declare that a property is implementing some property of the interface, for example:
在c#中,我只是通过声明该对象的部分类来完成此操作,并指出该对象实现了该接口,但是在basic不能正常工作的情况下,我认为这是因为用于表示某个属性正在实现某个属性的语言sintaxis接口,例如:
Public Property created_at() As Date Implements ICatalog.created_at
So is there any other way to accomplish this? 那么还有其他方法可以做到这一点吗?
I found the answer in an other cuestion after more time googling, I didn't found this using the stackoverflow search engine, the link is: 经过更多时间的谷歌搜索之后,我在另一个提示中找到了答案,但我没有使用stackoverflow搜索引擎找到它,链接是:
Partial Classes, LINQ, Interfaces and VB.NET 局部类,LINQ,接口和VB.NET
Just for the record Visual Basic sucks 仅作记录,Visual Basic很烂
Take a look at this example. 看一下这个例子。
Namespace MyAppDomain
Public Interface IFoo
Sub Bar()
End Interface
Public Interface IPerson
Function Gender() As String
End Interface
Public Class MyFooPerson : Implements IFoo, IPerson
Public Sub New()
End Sub
Public Sub Bar() Implements IFoo.Bar
End Sub
Public Function Gender() As String Implements IPerson.Gender
Return Nothing
End Function
End Class
End Namespace
You'll notice the MyFooPerson
Class implements the IFoo
Interface as well as the IPerson
Interface. 您会注意到
MyFooPerson
类实现了IFoo
接口以及IPerson
接口。 Each method then implements the corresponding Interface method. 每个方法然后实现相应的Interface方法。
Your example doesn't say whether or not the Class containing Public Property created_at() As Date Implements ICatalog.created_at
is Implementing the ICatalog
Interface. 您的示例没有说明包含
Public Property created_at() As Date Implements ICatalog.created_at
的类是否已Public Property created_at() As Date Implements ICatalog.created_at
正在实现ICatalog
接口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.