我需要在DNN安装中返回状态(区域)名称的键值配对列表及其缩写值。在下面的函数中,我成功地将所需结果获取到名为RegionList的推断变量,但是我无法将这些结果转换为键值配对列表或字典并返回结果。任何帮助将不胜感激。
Public Function GetRegionPerCountry(CountryCode As String) As List(Of KeyValuePair(Of String, String))
Dim lc As New DotNetNuke.Common.Lists.ListController()
Dim countryID As Integer
Dim RegionList2 As List(Of KeyValuePair(Of String, String)) = New List(Of KeyValuePair(Of String, String))
If Not CountryCode Is Nothing Then
Dim entryCollection As System.Collections.Generic.List(Of DotNetNuke.Common.Lists.ListEntryInfo)
entryCollection = lc.GetListEntryInfoItems("Country")
countryID = entryCollection.Where(Function(x) x.Value = CountryCode).Select(Function(x) x.EntryID).FirstOrDefault()
entryCollection = lc.GetListEntryInfoItems("Region")
Dim RegionList = entryCollection.Where(Function(x) x.ParentID = countryID).Select(Function(x) New With {.Key = x.Text.ToString(), .Value = x.Value.ToString()}).ToList()
RegionList2 = RegionList
End If
Return RegionList2
End Function