0

这是我尝试在 dotnet 中执行 webapi 的代码

    Public Function [Get]() As IEnumerable(Of user_data)
    Dim db As New databaseusersEntities
    Dim avg_users = (From p In db.user_data
              Select p.FullName).ToList()
    Return db.user_data.ToList()
    'Return avg_users.ToList()  --- this one doesn't work
    End Function

我想避免从 json 数据和全名中获取“实体密钥”,我使用 POCO/DTO 来防止但得到错误

“无法投射‘System.Collections.Generic.List 1[System.String]' to type 'System.Collections.Generic.IEnumerable1’类型的对象”

4

1 回答 1

0

将方法的返回类型更改为字符串

Public Function [Get]() As IEnumerable(Of String)
    Dim db As New databaseusersEntities
    Dim avg_users = (From p In db.user_data
              Select p.FullName).ToList()
    Return avg_users.ToList()
End Function
于 2012-07-18T07:59:16.120 回答