System.NotSupportedException

483 views Asked by At

I have been getting this "System.NotSupportedException" exception for a while now, I ran out of options. I get this error when I try to access the findAllUsers() funtion from my browser.

I have model class:

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

The ServiceAPIserver class has a function that looks like this:

 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
1

There are 1 answers

0
jmcilhinney On

When writing LINQ to Entities code at design time, it's LINQ so all LINQ syntax is supported. At run time though, certain things are not supported by the underlying provider. Most notably, your LINQ query must be able to be converted to SQL code that can be executed against the database. If wrapper.DecryptData is a method in your own VB code then your database knows nothing about it so it can't be converted to SQL so it's not supported by LINQ to Entities.