In Entity Framework 4, I\'m facing a problem when I use function import to a stored procedure and then using as a scalar value. It generates the code below:
Notice that the return type of GetTopEmployee is an ObjectResult<Nullable<int>>. ObjectResult<T> implements IEnumerable<T> so your method is capable of returning more than one Nullable<int>.
I assume you are trying to get some form of Id for the employee. If you are absolutely sure you are only going to get one result you could use the following code to get that Id.
var topId = db.GetTopEmployee().FirstOrDefault();
topId could be null. You will have to use topId.Value or var result = topId ?? -1; to get an int result.
NorthwindEntities db = new NorthwindEntities();
int j = db.GetTopEmployee().FirstOrDefault() ?? -1;