繁体   English   中英

如何指示Entity Framework对象正在实现接口?

[英]How to indicate that an Entity Framework object is implementing an interface?

好的,我必须开始说我正在使用Visual Basic。 问题是我有一个Entity Framework对象,并且想指出该对象实现了一个接口,例如:

Public Interface ICatalog
   Property created_at() As Date
   Property id() As Long
End Interface

这些属性已在对象中就绪。 在c#中,我只是通过声明该对象的部分类来完成此操作,并指出该对象实现了该接口,但是在basic不能正常工作的情况下,我认为这是因为用于表示某个属性正在实现某个属性的语言sintaxis接口,例如:

Public Property created_at() As Date Implements ICatalog.created_at

那么还有其他方法可以做到这一点吗?

经过更多时间的谷歌搜索之后,我在另一个提示中找到了答案,但我没有使用stackoverflow搜索引擎找到它,链接是:

局部类,LINQ,接口和VB.NET

仅作记录,Visual Basic很烂

看一下这个例子。

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

您会注意到MyFooPerson类实现了IFoo接口以及IPerson接口。 每个方法然后实现相应的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM