我创建了一个网络服务,它返回两个数据集(返回类型)作为结果。
是否可以将两个数据集结果合并为一个,以便我可以将其显示在一个数据列表中?我尝试使用 arraylist
但它在 datalist
中没有返回任何内容。
GetDepartureFlightsDetails()
和 getDepartureFlights()
都返回数据集值。
以下是我用来检索网络服务结果的方法。
public ArrayList GetDepartureFlightsDetails(String departurecountry, String arrivalcountry, DateTime departuredate)
{
DLSA datalayerTS = new DLSA();
DLJS datalayerJW = new DLJS();
ArrayList array = new ArrayList();
array.Add(datalayerSA.GetDepartureFlightsDetails(departurecountry, arrivalcountry, departuredate));
array.Add(datalayerJW.getDepartureFlights(departurecountry, arrivalcountry, departuredate));
return array;
}
最佳答案
您可以使用 DataSet.Merge方法:
firstDataSet.Merge(secondDataSet);
更新:
public DataSet GetDepartureFlightsDetails(String departurecountry, String arrivalcountry, DateTime departuredate)
{
DLSA datalayerTS = new DLSA();
DLJS datalayerJW = new DLJS();
var firstDataSet = datalayerSA.GetDepartureFlightsDetails(departurecountry, arrivalcountry, departuredate));
var secondDataSet = datalayerJW.getDepartureFlights(departurecountry, arrivalcountry, departuredate));
firstDataSet.Merge(secondDataSet);
return firstDataSet;
}
关于c# - 将数据集的两个结果合并为一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14117818/