我希望能够返回来自查询的所有“列表值”的列表。下面的“查询”从数据库返回多行结果,每行作为列表中的一个项目。从 db 返回的示例结果看起来像......
我放断点时的示例查询结果:(这是“查询”下方的第一行代码从数据库返回的内容)
- 姓名 = 约翰;地址 = 1230, Ewded ; listOfCities = "纽约、CH、洛杉矶"
- 姓名 = 埃里克;地址 = 12 , Ewded ; listOfCities = "BO, SE, OR"
代码:
List<Index.Result> query = getresultsbackfromdb();
// query content at this point looks like above 1,2
List<string> result = new List<string>();
foreach (var item in query)
{
results.Add(item.listCities);
//'results' list takes in string and not a list
//How do I return a consolidated list of items
}
return result; // this should have ""NY, CH, LA, BO, SE, OR"
//I am trying to get a list of all cities from 1,2 included in
//one single list.