[英]Combining two results of datasets into one
我創建了一個webservice,它返回兩個數據集(返回類型)作為結果。 是否可以將兩個數據集結果合並為一個,以便我可以在一個數據列表中顯示它? 我嘗試使用arraylist
但它在datalist
沒有返回任何內容。
GetDepartureFlightsDetails()
和getDepartureFlights()
都返回數據集值。
下面是我用來檢索Web服務結果的方法。
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;
}
你不能創建一個包裝類並使用包裝類的List<>
,而不是Datasets
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.