最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vb.net - Retrieving optionset text using latebound ASP.NET MVC - Stack Overflow

programmeradmin1浏览0评论

I am struggling to get the text value from the option set. This is an ASP.NET MVC project I am working on. The view returns the value of the option set but I want to display the text.

Public Shared Function RetriveRecords() As List(Of AccountEntityModels)
    Using service As OrganizationService = New OrganizationService("MyConnectionString")
        Dim query As QueryExpression = New QueryExpression With {
            .EntityName = "account",
            .ColumnSet = New ColumnSet("new_licencestatus")
        }
        Dim info As List(Of AccountEntityModels) = New List(Of AccountEntityModels)()
        Dim accountRecord As EntityCollection = service.RetrieveMultiple(query)

        If accountRecord IsNot Nothing AndAlso accountRecord.Entities.Count > 0 Then
            Dim accountModel As AccountEntityModels

            For i As Integer = 0 To accountRecord.Entities.Count - 1
                accountModel = New AccountEntityModels()
                If accountRecord(i).Contains("new_licencestatus") AndAlso accountRecord(i)("new_licencestatus") IsNot Nothing Then accountModel.LicenceStatusValue = (CType(accountRecord(i)("new_licencestatus"), OptionSetValue)).Value.ToString
                info.Add(accountModel)
            Next
        End If
        Return info
    End Using
End Function

AccountEntityModels:

Public Property LicenceStatus As OptionSetValue
Public Property LicenceStatusValue As String
发布评论

评论列表(0)

  1. 暂无评论