|
' ___________________________________________________
'
' � Hi-Integrity Systems 2007. All rights reserved.
' www.hisystems.com.au - Toby Wicks
' ___________________________________________________
'
Option Strict On
Option Explicit On
Namespace SQL
Public Class SQLSelectGroupByFields
Implements IEnumerable
Private pobjGroupByFields As ArrayList
Public Sub New()
MyBase.New()
pobjGroupByFields = New ArrayList
End Sub
Public Function Add() As SQLSelectGroupByField
Return Add("", Nothing)
End Function
Public Function Add( _
ByVal strFieldName As String) As SQLSelectGroupByField
Return Add(strFieldName, Nothing)
End Function
Public Function Add( _
ByVal strFieldName As String, _
ByVal objTable As SQLSelectTable) As SQLSelectGroupByField
Dim objFieldOrder As SQLSelectGroupByField
objFieldOrder = New SQLSelectGroupByField
With objFieldOrder
.Table = objTable
.Name = strFieldName
End With
pobjGroupByFields.Add(objFieldOrder)
Return objFieldOrder
End Function
Default Public ReadOnly Property Item(ByVal strFieldName As String) As SQLSelectGroupByField
Get
Return DirectCast(pobjGroupByFields.Item(FieldNameIndex(strFieldName)), SQLSelectGroupByField)
End Get
End Property
Default Public ReadOnly Property Item(ByVal intIndex As Integer) As SQLSelectGroupByField
Get
Return DirectCast(pobjGroupByFields.Item(intIndex), SQLSelectGroupByField)
End Get
End Property
Public ReadOnly Property Count() As Integer
Get
Return pobjGroupByFields.Count()
End Get
End Property
Friend ReadOnly Property SQL(ByVal eConnectionType As Database.ConnectionType) As String
Get
Dim strSQL As String
For intIndex As Integer = 0 To Me.Count - 1
strSQL &= Me.Item(intIndex).SQL(eConnectionType)
If intIndex <> Me.Count - 1 Then
strSQL &= ", "
End If
Next
Return strSQL
End Get
End Property
Public Function Exists(ByVal strFieldName As String) As Boolean
Return FieldNameIndex(strFieldName) >= 0
End Function
Public Sub Delete(ByRef objGroupByField As SQLSelectGroupByField)
If Not pobjGroupByFields.Contains(objGroupByField) Then
Throw New ObjectDoesNotExistException
End If
pobjGroupByFields.Remove(objGroupByField)
objGroupByField = Nothing
End Sub
Private Function FieldNameIndex(ByVal strFieldName As String) As Integer
Dim objGroupByField As SQLSelectGroupByField
strFieldName = strFieldName.Trim()
For intIndex As Integer = 0 To Me.Count - 1
objGroupByField = DirectCast(pobjGroupByFields.Item(intIndex), SQLSelectGroupByField)
If String.Compare(strFieldName, objGroupByField.Name, ignoreCase:=True) = 0 Then
Return intIndex
End If
Next
Return -1
End Function
Private Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return pobjGroupByFields.GetEnumerator
End Function
End Class
End Namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.