Monday, May 02, 2022

LINQ to Entities does not recognize the method 'System.String GetUserId(System.Security.Principal.IIdentity)' method, and this method cannot be translated into a store expression. Source=EntityFramework

 This exception occurs because LINQ to SQL query internally builds an SQL query and executes it on the database directly and hence when one tries to use the ToString method which is a .Net data type conversion method and cannot be used for an SQL Query.

 Solution to this problem is to use the StringConvert method of the SqlFunctions class for converting the Integer value to String.

No comments:

Post a Comment