I have the following code:
Expression<Func<int, string>> myStatusCode = (t) => PluginApplication.Types.ToTypeName(t);
var model =_context.UsersRepository.Include("Emails").Include("Website").
Include("UserDetail").Include("Profile").AsExpandable().Where(t => t.TypeId == (UserType)10017).Select(t=> new
{
UserId = t.UserId,
UserName = t.UserName,
ChatName = t.ChatName,
Email = t.Emails.FirstOrDefault(z => z.TypeId == EmailType.Main).EmailAddress,
LastLoginDate = t.LastLoginDate,
StatusId = t.StatusId,
Website = t.SignedUpOnWebsite.ShortName,
StatusCode = myStatusCode.Invoke((int)t.StatusId)
});
Here I'm using LinqKit which seems to help me call a method when select some data without Take expresion AsEnumerable.If I put ToList or AsEnumerable , will work well, but I don't wanna do this.I want to find something to avoid the error :
LINQ to Entities does not recognize the method'PluginApplication.Types.ToTypeName (System.Int32)' method, and this method cannot be translated into a store expression.