将一个函数中的多个数据传递到C#中的标签
本文关键字:标签 数据 一个 函数 | 更新日期: 2023-09-27 18:00:32
我有一个函数可以检索多行数据,并希望将它们显示在标签中。我的功能如下所示。
public static string GetItemByQuery(IAmazonSimpleDB simpleDBClient, string domainName)
{
SelectResponse response = simpleDBClient.Select(new SelectRequest()
{
SelectExpression = "Select * from " + domainName
});
String res = domainName + " has: ";
foreach (Item item in response.Items)
{
res = item.Name + ": ";
foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attributes)
{
res += "{" + attribute.Name + ", " + attribute.Value + "}, ";
}
res = res.Remove(res.Length - 2);
}
return res;
}
到目前为止,我只能返回一个字符串,它是检索到的数据的最后一行。如何检索所有记录?我尝试了arraylist,但AWS web应用程序似乎不允许我使用arraylist。有人能帮我解决这个问题吗??
将其作为可枚举的返回
List<String> Results ;
你的方法是
public static List<String> GetItemByQuery(IAmazonSimpleDB simpleDBClient, string domainName)
{
List<String> Results = null;
SelectResponse response = simpleDBClient.Select(new SelectRequest()
{
SelectExpression = "Select * from " + domainName
});
String res = domainName + " has: ";
foreach (Item item in response.Items)
{
Results = new List<String>();
res = item.Name + ": ";
foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attributes)
{
res += "{" + attribute.Name + ", " + attribute.Value + "}, ";
}
res = res.Remove(res.Length - 2);
Results.Add(res);
}
return Results;
}