C# 将两个数据集结果合二为一

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14117818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 10:43:37  来源:igfitidea点击:

Combining two results of datasets into one

c#web-servicesdatasetdatalist

提问by FredHomme

I have created a webservice which returns two datasets(return type) as results. Is it possible to combine two datasets results into one so that I can display it on one datalist? I try using arraylistbut it returns nothing in datalist.

我创建了一个 web 服务,它返回两个数据集(返回类型)作为结果。是否可以将两个数据集结果合并为一个,以便我可以将其显示在一个数据列表中?我尝试使用,arraylist但它在datalist.

GetDepartureFlightsDetails()and getDepartureFlights()both returns a dataset values.

GetDepartureFlightsDetails()并且getDepartureFlights()都返回一个数据集值。

Below is the method i use to retrieve the webservice results.

下面是我用来检索网络服务结果的方法。

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;
}

采纳答案by Eren Ers?nmez

You can use the DataSet.Mergemethod:

您可以使用DataSet.Merge方法:

firstDataSet.Merge(secondDataSet);


Update:

更新:

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;
}

回答by ankur

Can't you make a wrapper Class and use List<>of the wrapper class , rather than Datasets.

你不能创建一个包装类并使用List<>包装类,而不是Datasets.