小编Bre*_*ett的帖子

我只是不明白如何使用Linq

我有一个课程如下:

Class Scan
    Delivered As Boolean
    ScanDate As Date
    State As String
    Facility As String  
End Class
Run Code Online (Sandbox Code Playgroud)

然后我创建一个列表并用包含任何内容的扫描填充它.

Dim Scans As New List(Of Scan) 
Run Code Online (Sandbox Code Playgroud)

我需要挖掘清单以获取各种信息.我想用LINQ来做.问题是,对于我的生活,我只是没有得到它.语法将我抛弃,结果不是强类型的事实会让我失望,并且Web上的示例过于简单或过于复杂.

我怎么能

  1. 获取扫描计数,按日期分配Delivered = True
  2. 获取扫描计数,按设施分组,其中Delivered = True
  3. 获取扫描计数,按状态分组,其中Delivered = True

然后我想在For Each循环中使用它.

For Each result In GroupedResults
    ‘My Code

Next
Run Code Online (Sandbox Code Playgroud)

理想情况下,我希望结果是强类型的.这可能吗?

任何人都可以推荐一些链接来开始这个?我遇到的每个网站都让我头脑发热.我根本不理解它.

编辑:

十分感谢大家.我仍然对这些东西感到头疼,但至少这是一个真实世界的例子,我可以用它来了解发生了什么.

我希望这个简单的例子可以帮助我进入一个更复杂的用途 - 没有运气.我本来应该这样做了.

所有示例似乎都使用键/值响应.如果我需要分组两个值,该怎么办?

    Class Scan
        Delivered As Boolean
        Scanned As Boolean
        ScanDate As Date
        State As String
        Facility As String  
    End Class


1. Get a count of Delivered = True, …
Run Code Online (Sandbox Code Playgroud)

linq vb.net

5
推荐指数
1
解决办法
396
查看次数

.NET Web服务。(ASMX)如何调整请求和响应消息?

我正在构建一个Web服务来接受公司的通知。该公司通知我该服务的结构不正确,并向我提供了可运行的Web服务的.asmx。看起来像这样:

请求:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <AuthenticationInfo
           xmlns="http://www.usps.com/postalone/services/UserAuthenticationSchema">
      <UserId xmlns="">string</UserId>
      <UserPassword xmlns="">string</UserPassword>
    </AuthenticationInfo>
    <fullServiceAddressCorrectionNotification
            xmlns="http://www.usps.com/postalone/services/POCustomerMailXMLServices">string</fullServiceAddressCorrectionNotification>
  </soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)

响应:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <FullServiceNixieDetailNotificationResponse
         xmlns="http://idealliance.org/maildat/Specs/md091/mailxml70C/mailxml">
      <FullServiceNixieDetailNotificationResult>string</FullServiceNixieDetailNotificationResult>
    </FullServiceNixieDetailNotificationResponse>
  </soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)

我的看起来像这样:请求:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <FullServiceNixieDetailNotification
          xmlns="http://idealliance.org/maildat/Specs/md091/mailxml70C/mailxml">
      <AuthenticationInfo>
        <UserID>string</UserID>
        <Password>string</Password>
      </AuthenticationInfo>
      <fullServiceAddressCorrectionNotification>string</fullServiceAddressCorrectionNotification>
    </FullServiceNixieDetailNotification>
  </soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)

响应:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <notificationResponse
       xmlns="http://www.usps.com/postalone/services/POCustomerMailXMLServices">string</notificationResponse>
  </soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)

如您所见,我的东西包裹在一个我需要摆脱的额外元素中。Unfortunatley,我不确定如何执行此操作。我的Web服务代码如下:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data.SqlClient

Public Structure AuthenticationInfoType …
Run Code Online (Sandbox Code Playgroud)

vb.net web-services asmx

2
推荐指数
1
解决办法
4160
查看次数

标签 统计

vb.net ×2

asmx ×1

linq ×1

web-services ×1