开发者

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

This question already has answers here: Partial Classes, LINQ, Interfaces and VB.NET (2 answers) Closed 2 years ago.

OK, I have to begin saying that I'm working with 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:

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 prop开发者_运维百科erty is implementing some property of the interface, for example:

Public Property created_at() As Date Implements ICatalog.created_at

So is there any other way to accomplish this?


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. Each method then implements the corresponding Interface method.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜