表位置的值为
var location = (from loc in Locations select (loc));
我明白了:
如果我想添加不在该表中的值(即“未找到”),我该怎么办?
答案 0 :(得分:1)
var location = (from loc in Locations select (loc)).FirstOrDefault();
这将为您提供null默认值,您可以处理显示“NotFound”。
答案 1 :(得分:1)
(from loc in Locations select loc)
.Concat(from loc in new[] { "Not Found" } select loc);
或者,在其他语法中:
Locations.Concat(new[] { "Not Found" });
答案 2 :(得分:0)
怎么样?
location.ToList().Add(new Location() { LocationId = 0, Name = "Not Found"});