getCollectionByAttributesWithEqualTo in CpersistentObject with order:
'''-----------------------------------------------------------------------------
''' <summary>
''' Gets all objects for a class that match an number of attribute values.
''' </summary>
''' <param name="colAttributes">A collection of attributes names</param>
''' <param name="pOrderCol">Collection of attributes (strings) to order by.</param>
''' <param name="pOrderAscCol">Collection of attributes (strings) to ordering ascendingly.</param>
''' <returns>A CPersistentCollection containing the matching objects.</returns>
''' <remarks>The object that the method is called against must have the
''' values of the named attributes set. These values are used to build a
''' retrieveCriteria object.
''' <para>The retrieveCriteria is then performed and the resulting objects
''' instantiated and added to the CPersistentCollection.</para></remarks>
''' <history>
''' [Marcos Flavio de Oliviera - mfo@cdtn.br] 18/12/2003 Created
''' [Marcos Flavio de Oliviera - mfo@cdtn.br] 01/10/2004 Include ordering.
''' </history>
'''-----------------------------------------------------------------------------
Public Function getCollectionByAttributesWithEqualTo(ByVal colAttributes As Collection, ByVal pOrderCol As Collection, ByVal pOrderAscCol As Collection) As CPersistentCollection
Dim obAux As Object
Dim obCol As CPersistentCollection
Dim obRC As New CRetrieveCriteria
Dim obCursor As CCursor
Dim obCC As New CCriteriaCondition
Dim stAttribute As String
Dim inIndex As Integer
Dim boAscend As Boolean
For Each stAttribute In colAttributes
obCC.addSelectEqualTo(stAttribute, Me.getValueByAttribute(stAttribute))
Next
obRC.WhereCondition = obCC
' If the collection isn't nothing.
If Not IsNothing(pOrderCol) Then
' For each attribute in collection, add a order attribute in retrieve criteria.
For inIndex = 1 To pOrderCol.Count
boAscend = True
If Not IsNothing(pOrderAscCol) Then
If inIndex <= pOrderAscCol.Count Then
' If the item for ascend is false.
If Not pOrderAscCol(inIndex) Then
boAscend = False
End If
End If
End If
obRC.addOrderAttributeByAscend(pOrderCol(inIndex), boAscend)
Next
End If
obCol = New CPersistentCollection
Do While Not obCursor.EOF
obAux = Me.getNewObject
obCursor.loadObject(obAux)
obCol.Add(obAux)
obCursor.nextCursor()
Loop
Return obCol
End Function
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Corretion in signature of function:
Public Function getCollectionByAttributesWithEqualTo(ByVal colAttributes As Collection, Optional ByVal pOrderCol As Collection = Nothing, Optional ByVal pOrderAscCol As Collection = Nothing) As CPersistentCollection
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
getCollectionByAttributesWithEqualTo in CpersistentObject with order:
'''-----------------------------------------------------------------------------
''' <summary>
''' Gets all objects for a class that match an number of attribute values.
''' </summary>
''' <param name="colAttributes">A collection of attributes names</param>
''' <param name="pOrderCol">Collection of attributes (strings) to order by.</param>
''' <param name="pOrderAscCol">Collection of attributes (strings) to ordering ascendingly.</param>
''' <returns>A CPersistentCollection containing the matching objects.</returns>
''' <remarks>The object that the method is called against must have the
''' values of the named attributes set. These values are used to build a
''' retrieveCriteria object.
''' <para>The retrieveCriteria is then performed and the resulting objects
''' instantiated and added to the CPersistentCollection.</para></remarks>
''' <history>
''' [Marcos Flavio de Oliviera - mfo@cdtn.br] 18/12/2003 Created
''' [Marcos Flavio de Oliviera - mfo@cdtn.br] 01/10/2004 Include ordering.
''' </history>
'''-----------------------------------------------------------------------------
Public Function getCollectionByAttributesWithEqualTo(ByVal colAttributes As Collection, ByVal pOrderCol As Collection, ByVal pOrderAscCol As Collection) As CPersistentCollection
Dim obAux As Object
Dim obCol As CPersistentCollection
Dim obRC As New CRetrieveCriteria
Dim obCursor As CCursor
Dim obCC As New CCriteriaCondition
Dim stAttribute As String
Dim inIndex As Integer
Dim boAscend As Boolean
obRC.ClassMap = Me.getClassMap(Me)
obCC.ClassMap = Me.getClassMap(Me)
For Each stAttribute In colAttributes
obCC.addSelectEqualTo(stAttribute, Me.getValueByAttribute(stAttribute))
Next
obRC.WhereCondition = obCC
' If the collection isn't nothing.
If Not IsNothing(pOrderCol) Then
' For each attribute in collection, add a order attribute in retrieve criteria.
For inIndex = 1 To pOrderCol.Count
boAscend = True
If Not IsNothing(pOrderAscCol) Then
If inIndex <= pOrderAscCol.Count Then
' If the item for ascend is false.
If Not pOrderAscCol(inIndex) Then
boAscend = False
End If
End If
End If
obRC.addOrderAttributeByAscend(pOrderCol(inIndex), boAscend)
Next
End If
obCursor = obRC.perform(Me)
obCursor.HoldsProxies = False
obCol = New CPersistentCollection
Do While Not obCursor.EOF
obAux = Me.getNewObject
obCursor.loadObject(obAux)
obCol.Add(obAux)
obCursor.nextCursor()
Loop
Return obCol
End Function
Corretion in signature of function:
Public Function getCollectionByAttributesWithEqualTo(ByVal colAttributes As Collection, Optional ByVal pOrderCol As Collection = Nothing, Optional ByVal pOrderAscCol As Collection = Nothing) As CPersistentCollection