![](/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.