Database System.NotSupportedException

Database System.NotSupportedException,database,vb.net,entity-framework,wcf-web-api,Database,Vb.net,Entity Framework,Wcf Web Api,我得到这个“System.NotSupportedException”异常已经有一段时间了,我已经没有选择了。当我试图从浏览器访问findAllUsers()函数时,出现此错误 我有模型课: Public Class pUsers Public Property UserId() As Long Public Property Username() As String Public Property Password() As String Public Property Email() As

我得到这个“System.NotSupportedException”异常已经有一段时间了,我已经没有选择了。当我试图从浏览器访问findAllUsers()函数时,出现此错误

我有模型课:

Public Class pUsers

Public Property UserId() As Long
Public Property Username() As String
Public Property Password() As String
Public Property Email() As String
Public Property Cell() As String
Public Property DateCreated() As Date
Public Property LastLogin() As DateTime

End Class
ServiceAPIserver类具有如下函数:

 Public Function findAllUsers() As List(Of pUsers) Implements IServiceAPIServer.findAllUsers
    Using mde As New AllMyAPIEntities()
        Return mde.UserEntities.[Select](Function(ue) New pUsers() With {
            .UserId = ue.UserId,
            .Cell = wrapper.DecryptData(ue.Cell),
            .DateCreated = ue.DateCreated,
            .Email = wrapper.DecryptData(ue.Email),
            .LastLogin = ue.LastLogin,
            .Password = ue.Password,
            .Username = wrapper.DecryptData(ue.Username)}).ToList()
    End Using
End Function

在设计时将LINQ写入实体代码时,它是LINQ,因此支持所有LINQ语法。但在运行时,底层提供程序不支持某些内容。最值得注意的是,LINQ查询必须能够转换为可以针对数据库执行的SQL代码。如果
wrapper.DecryptData
是您自己的VB代码中的一个方法,那么您的数据库对此一无所知,因此无法将其转换为SQL,因此LINQ to Entities不支持该方法。

为什么您的问题中有这么多错误的标记?这是因为我不知道错误的原因。@但是,您不仅得到了一个
NotSupportedException
,还得到了一个
NotSupportedException
告诉您问题的确切位置。如果你不了解细节,很好,这可以成为一个很好的问题,但是如果你甚至懒得读一点书并尝试去理解,你所做的就比把手举在空中说“哇啊哈!!!”@jmcilhinney,非常感谢你。