Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to resolve this error
This function can only be invoked from LINQ to Entities.

The code which causes this error:
C#
var usrModel = new UserRegisterModel();

Country curid = snwe.Countries.Where(a => a.Country1 == "India").FirstOrDefault();

usrModel.Countries = snwe.Countries.AsEnumerable().Select(C => new SelectListItem {
   Text = C.Country1,
   Value = SqlFunctions.StringConvert((double)C.CountryID).Trim(),
   Selected = C.CountryID == curid.CountryID ? true : false
});
Posted
Updated 14-Oct-15 23:25pm
v2
Comments
Tomas Takac 15-Oct-15 5:29am    
Try to remove AsEnumerable(): snwe.Countries.Select(...

1 solution

It's probably the SqlFunctions line. If you just want to convert to string;

Value = C.CountryID.ToString().Trim(),
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900