我想在此查詢中返回實際值,但我只獲取表達式。請有人指點我正確的方向。理解LINQ返回值的問題
public static String NurseName(Guid? userID)
{
var nurseName = from demographic in context.tblDemographics
where demographic.UserID == userID
select new {FullName = demographic.FirstName +" " + demographic.LastName};
String nurseFullName = nurseName.ToString();
return nurseFullName;
}
nurseFullName作爲結束 - >SELECT ([t0].[FirstName] + @p1) + [t0].[LastName] AS [FullName] FROM [dbo].[tblDemographics] AS [t0] WHERE ([t0].[UserID]) = @p0
請記住,查詢表達式的值是一個表示查詢*的對象。該對象具有很好的屬性,當你讓它枚舉它時,它會運行查詢。但是對象本身不是*結果*,它是*查詢*。 – 2009-09-25 19:40:11
@Eric:謝謝。這有助於我理解它。 – 2009-09-25 19:55:49