从Web服务中检索不同的数据 [英] Retreiving Distinct data from a webservice

查看:58
本文介绍了从Web服务中检索不同的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我们需要将webservice结果绑定到下拉列表中,但问题是重复的countryname是绑定的。



实际上,Web服务SOAP O / P包含80个值,其中有重复项。我们需要避免使用LINQ查询进行复制。



使用webservice绑定下拉列表的查询如下。



 myICTCReceCountry = myICTCWebService.GetReceivingCountry(myICTCRecCountrySOAPIn).Records 

对于 i 作为 整数 = < span class =code-digit> 0 myICTCReceCountry.Length - 1
' ddlCountry.DataTextField = myICTCReceCountry(i).Country_Name
' < span class =code-comment> ddlCountry.DataValueField = myICTCReceCountry(i).Destination_Country
ddlCountry.Items.Insert(i, New ListItem(myICTCReceCountry(i).Country_Name,myICTCReceCountry(i).Destination_Country))
下一页







请帮助



问候

Sreejith

解决方案

  Dim  lst =来自 In  myICTCReceCountry_ 
按a_
排序选择 使用 {Key a.Country_Name,a.Destination_Country} Distinct.ToList

对于 每个 lr lst
ddlCoun try.DataTextField = lr.Country_Name;
ddlCountry.DataValueField = lr.Destination_Country;
下一步


根据我的理解,您希望获得非重复值。因此,您需要使用 Group By Clause [ ^ ]或不同的方法 [ ^ ]值;)



更多信息,请参阅:

如何:计算,求和或平均数据使用LINQ(Visual Basic) [ ^ ]

Hi,

We need to bind a webservice result into a dropdownlist,but the problem is duplicate countryname is binding.

Actually the webservice SOAP O/P contains 80 values in which duplicates are there.We need to avoid teh duplication using LINQ query.

The query to bind the dropdownlist using webservice is below.

myICTCReceCountry = myICTCWebService.GetReceivingCountry(myICTCRecCountrySOAPIn).Records

               For i As Integer = 0 To myICTCReceCountry.Length - 1
                   'ddlCountry.DataTextField = myICTCReceCountry(i).Country_Name
                   'ddlCountry.DataValueField = myICTCReceCountry(i).Destination_Country
                   ddlCountry.Items.Insert(i, New ListItem(myICTCReceCountry(i).Country_Name, myICTCReceCountry(i).Destination_Country))
               Next




Please help

Regards
Sreejith

解决方案

Dim lst = From a In myICTCReceCountry_
          Order By a_
          Select New With {Key a.Country_Name, a.Destination_Country}Distinct.ToList

      For Each lr In lst  
              ddlCountry.DataTextField = lr.Country_Name;
                ddlCountry.DataValueField = lr.Destination_Country;
      Next


As per my understanding, you want to get non-duplicated values. So, you need to use Group By Clause[^] or Distinct method[^] values ;)

For further information, please see:
How to: Count, Sum, or Average Data by Using LINQ (Visual Basic)[^]


这篇关于从Web服务中检索不同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆