![](/img/trans.png)
[英]entity framework, how to use object query with a WHERE, AND to retrieve entity record
[英]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
那么還有其他方法可以做到這一點嗎?
看一下這個例子。
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.