Asp.net 如何以字符串形式存储查询值

Asp.net 如何以字符串形式存储查询值,asp.net,asp.net-mvc,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(); 听起来像是你想要的 string CityName =

在下面的查询中,我必须将列CityName和StateAbbr的值存储在两个字符串中。如何仅使用一个查询来实现这一点

var GetLocation= (
      from results in db1.ZipCodes1 
      where results.ZIPCode==zipcode 
      select new { results.CityName, results.StateAbbr }
).First();
听起来像是你想要的

 string CityName = GetLocation.CityName;
 string  StateAbbr = GetLocation.StateAbbr;
请参阅问题以获取答案。