如何在字符串中存储查询的值

时间:2011-05-27 12:11:42

标签: asp.net asp.net-mvc

我必须在以下查询中将CityName和StateAbbr列的值存储在两个字符串中,如何只使用一个查询来执行此操作

var GetLocation= (
      from results in db1.ZipCodes1 
      where results.ZIPCode==zipcode 
      select new { results.CityName, results.StateAbbr }
).First();

1 个答案:

答案 0 :(得分:0)

听起来像你想要的

 string CityName = GetLocation.CityName;
 string  StateAbbr = GetLocation.StateAbbr;