按属性值和值列表过滤类别列表

问题描述 投票:0回答:1

我有一个绑定到自定义类的Devexpress Gridcontrol。

这个类看起来像这样:

  Public Class AuditList
            Public CasualtyList As List(Of CasualtyRecords)
            Public MedsList As List(Of CasualtyRecords.Medications)

            Public Property FilterString As CriteriaOperator

            Public Sub New()
                CasualtyList = New List(Of CasualtyRecords)
                MedsList = New List(Of CasualtyRecords.Medications)
            End Sub

            Public Class CasualtyRecords
                Private _primary As New PS
                Public Property PrimarySurvey As PS
                    Get
                        Return _primary
                    End Get
                    Set(value As PS)
                        _primary = value
                    End Set
                End Property

                Public Sub New()
                    Vitals = New List(Of VitalRecords)
                End Sub
                Public Property Vitals As List(Of VitalRecords)
                Public Property Meds As List(Of Medications)

                ReadOnly Property MedCount As Integer
                    Get
                        Return Meds.Count
                    End Get
                End Property

                Property Id As Integer
                Property ClinicalImpression As String
                Property Disposal As String
                Property Age As Integer
                Property Gender As String

                Class PS
                    Public Property Airway As Integer
                    Public Property Breathing As Integer
                    Public Property Circulation As Integer
                    Public Property Rate As Integer
                 End Class

               Class Medications
                    Public Property MedName As String
               End Class
            End Class
        End Class

这是我尝试创建的过滤器类型的示例:

“[性别] ='男性'和[药物]。[MedName] ='扑热息痛'和[年龄]> 100”

这是否可以使用如图所示构造的类,或者我是否需要实现其他一些接口?

我想用LINQ会看起来像这样

  Dim b As New CasualtyRecords
  b = a.CasualtyList.Where(Function(x) x.Meds.Any(Medications.Med = "Paracetamol") And x.Gender = "Male" And x.Age > 20)

谢谢

vb.net filtering
1个回答
0
投票

我能够使用此LINQ查询获得所需的结果

Dim newrecords = a.CasualtyList.Where(
        Function(x) x.Meds.Any(
            Function(b) b.MedName = "Paracetamol") _
            And x.Gender = "Male" And x.Age > 20).ToList()
© www.soinside.com 2019 - 2024. All rights reserved.