Since you're using LINQ, the expression only gets evaluated when the results are really needed. Note that select actually returns an IEnumerable
or IQueryable
. It's only if actually want to use the values that it executes the query. The default ToString()
method just prints the query.
You could for example call the ToList()
method to make sure the query is exectuted:
var prospects = pro.Select(p => p.ProspectName).ToList();
However, this will return a list of prospects, calling the ToString()
-method on that would still yield just the name of the type. If you want the first item of the list you can do the following:
var firstProspectName = pro.Select(p => p.ProspectName).First():
EDIT: Your query could be written a bit more concise, without intermediate steps:
var firstProspectName = db.Prospect.where(p => p.ProspectID == intPR)
.Select(p => p.ProspectName)
.First();