【发布时间】:2012-04-11 11:19:06
【问题描述】:
我有以下代码:
Private Sub setDropdowns()
Using licensingModel As New licensingEntities
SetUpDropdowns(licensingModel.tblLookup_Country, "CountryName", "CountryName", country)
SetUpDropdowns(licensingModel.tblLookup_Country, "CountryName", "CountryName", bizCountry)
SetUpDropdowns(licensingModel.tblLookup_Salutation, "SSalutation", "SSalutation", salutation)
SetUpDropdowns(licensingModel.tblLookup_OrgType, "OrgType", "OTAuto", organisationType)
End Using
End Sub
和子SetUpDropdowns:
Private Sub SetUpDropdowns(ByVal entity As IObjectSet(Of EntityObject), ByVal textColumn As String, ByVal valueColumn As String, ByVal combo As RadComboBox)
combo.DataSource = entity
combo.DataBind()
End Sub
我的问题是我不知道如何为 sub 定义参数类型。因为它们是每次传递的不同类型的对象集,我认为IObjectSet(Of EntityObject) 会起作用,但它给了我以下错误:
无法转换类型为“System.Data.Objects.ObjectSet
1[licensingModel.tblLookup_Country]' to type 'System.Data.Objects.IObjectSet1[System.Data.Objects.DataClasses.EntityObject]”的对象
有人能解决这个问题吗?
【问题讨论】:
-
这是错误顺便说一句:无法转换类型为“System.Data.Objects.ObjectSet
1[licensingModel.tblLookup_Country]' to type 'System.Data.Objects.IObjectSet1[System.Data.Objects.DataClasses.EntityObject]”的对象。 -
欢迎来到 SO,第一个问题 +1。
-
你试过定义泛型方法吗?
-
我可以使用泛型。但我认为我可以使用我在上面尝试的其他方法,因为我认为它会更好?
标签: asp.net vb.net entity-framework