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

时间:2018-01-03 17:35:47

标签: vb.net filtering

我将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] ='扑热息痛' AND [年龄]> 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)

由于

1 个答案:

答案 0 :(得分: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()