小编wav*_*rop的帖子

Linq Group on Multiple Fields - VB.NET,Anonymous,Key

我很难过.我需要帮助.我有一个带有重复患者地址数据的DTO对象.我只需要获得唯一的地址.

Dim PatientAddressDto = New List(Of PatientAddress)

{Populate PatientAddressDto with lots of duplicate data}

PatientAddressDto = (From d In PatientAddressDto
                    Group d By PatientAddressDtoGrouped = New PatientAddress With {
                                                              .Address1 = d.Address1,
                                                              .Address2 = d.Address2,
                                                              .City = d.City,
                                                              .State = d.State,
                                                              .Zip = d.Zip
                                                              }
                  Into Group
                  Select New PatientAddress With {
                                                  .Address1 = PatientAddressDtoGrouped.Address1,
                                                  .Address2 = PatientAddressDtoGrouped.Address2,
                                                  .City = PatientAddressDtoGrouped.City,
                                                  .State = PatientAddressDtoGrouped.State,
                                                  .Zip = PatientAddressDtoGrouped.Zip
                                                  }).ToList()
Run Code Online (Sandbox Code Playgroud)

我试过以下没有运气:

PatientAddressDto = (From d In PatientAddressDto
                    Select New PatientAddress With { …
Run Code Online (Sandbox Code Playgroud)

linq vb.net linq-to-objects

16
推荐指数
2
解决办法
2万
查看次数

标签 统计

linq ×1

linq-to-objects ×1

vb.net ×1