-1

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
Rich Benner
  • 7,873
  • 9
  • 33
  • 39
kilojoules88
  • 51
  • 1
  • 11
  • Why all those wrong tags in your question? – B001ᛦ Apr 27 '16 at 08:30
  • That was because I don't really know what causes the error. @ bub – kilojoules88 Apr 27 '16 at 08:47
  • 1
    You didn't just get a `NotSupportedException`, you got a `NotSupportedException` telling you exactly where the problem is. If you don't understand the details, fine, that can make for a good question, but if you don't even bother to do a minimal read and attempt to understand, what you're doing is little better than just throwing your hands in the air and going "waaahhhhh!!!" –  Apr 27 '16 at 08:50
  • @jmcilhinney, Thank you very much. – kilojoules88 Apr 27 '16 at 09:17

1 Answers1

0

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.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46