-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuery.cls
78 lines (63 loc) · 2.18 KB
/
Query.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Query"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' Version 1.1.1
'@Folder("CodeBase.Classes.Queries")
Option Explicit
Private Type TQuery
QueryMode As QueryMode
Parameters As Collection
End Type
Private this As TQuery
Implements IQuery
Private Sub Class_Initialize()
Set this.Parameters = New Collection
End Sub
Private Sub IQuery_AddParameter(ByVal ParameterName As String, ByVal ParameterValue As Variant, ByVal ParameterMatchType As MatchType, ByVal ParameterCondition As MatchCondition)
Dim Parameter As IQueryParameter
Set Parameter = New QueryParameter
Parameter.Create ParameterName, ParameterValue, ParameterMatchType, ParameterCondition
If Not Parameter.IsUndefined Then
this.Parameters.Add Parameter
End If
End Sub
Public Property Get IQuery_Parameters() As Collection
Set IQuery_Parameters = this.Parameters
End Property
Private Property Get IQuery_Mode() As QueryMode
IQuery_Mode = this.QueryMode
End Property
Private Property Let IQuery_Mode(Value As QueryMode)
this.QueryMode = Value
End Property
Private Property Get IQuery_SatisfiesParameters(ByVal Record As IQueryableRecord) As Boolean
If this.QueryMode = qmAndMode Then
IQuery_SatisfiesParameters = SatisfiesAndMode(Record)
Else
IQuery_SatisfiesParameters = SatisfiesOrMode(Record)
End If
End Property
Private Function SatisfiesAndMode(ByVal Record As IQueryableRecord) As Boolean
Dim Parameter As IQueryParameter
For Each Parameter In this.Parameters
If Not Parameter.SatisfiesComparison(Record.GetNamedProperty(Parameter.PropertyName)) Then
Exit Function
End If
Next
SatisfiesAndMode = True
End Function
Private Function SatisfiesOrMode(ByVal Record As IQueryableRecord) As Boolean
Dim Parameter As IQueryParameter
For Each Parameter In this.Parameters
If Parameter.SatisfiesComparison(Record.GetNamedProperty(Parameter.PropertyName)) Then
SatisfiesOrMode = True
Exit Function
End If
Next
End Function