Click here to Skip to main content
14,268,557 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to resolve this error
This function can only be invoked from LINQ to Entities.

The code which causes this error:
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
Updated 14-Oct-15 23:25pm
Tomas Takac 15-Oct-15 5:29am
Try to remove AsEnumerable(): snwe.Countries.Select(...

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

Value = C.CountryID.ToString().Trim(),

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100