---
title: clsAgencyCollection
summary: API reference for clsAgencyCollection.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-31
library: SAIF.Business.Policy.Agency
reference_type: package
---

# clsAgencyCollection

`clsAgencyCollection` is the collection façade for agency retrieval and in-memory filtering. It retrieves agency sets, exposes convenience subsets such as direct writers or commission-held agencies, and provides the bulk child-loading helpers that prevent N+1 producer and contract retrieval.

## Purpose
- Retrieve all agencies or filtered agency subsets through the BOF collection lifecycle.
- Provide reusable in-memory filters for common agency classification scenarios.
- Bulk-load child producers and contracts into already-loaded agencies.

## Context
- Namespace: `SAIF.Business.Policy.Agency`
- Assembly/package: `SAIF.Business.Policy.Agency`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `Item` (index) | `Default Public ReadOnly Property Item(ByVal Index As Integer) As clsAgency` | Returns the agency at the given zero-based position in the collection. |
| `Item` (key) | `Default Public ReadOnly Property Item(ByVal inAgencySeqNum As String) As clsAgency` | Looks up an agency in the collection by its agency sequence number. |
| `CurrentItem` | `Public Shadows ReadOnly Property CurrentItem() As clsAgency` | Returns the agency at the collection's current cursor position, typed as `clsAgency` rather than the base collection's untyped current item. |
| `Active` | `Public ReadOnly Property Active(ByVal inDate As Date) As clsAgencyCollection` | Returns only agencies active on the requested date. |
| `ActiveProducerCommissionContract` | `Public ReadOnly Property ActiveProducerCommissionContract(ByVal inDate As Date) As clsAgencyCollection` | Returns agencies that have an active producer commission contract as of the requested date. |
| `ActiveAgencyOffices` | `Public ReadOnly Property ActiveAgencyOffices(ByVal inDate As Date) As clsAgencyOfficeCollection` | Aggregates active offices across the agency set into one detached collection. |
| `CheckLimitNotOverridable` | `Public ReadOnly Property CheckLimitNotOverridable() As clsAgencyCollection` | Returns agencies that are not permitted to override the standard check-issuance limit. |
| `CheckLimitOverridable` | `Public ReadOnly Property CheckLimitOverridable() As clsAgencyCollection` | Returns agencies that are permitted to override the standard check-issuance limit. |
| `ContractTypes` | `Public ReadOnly Property ContractTypes(ByVal inAgencyContractTypes As Generic.List(Of clsAgencyContract.AgencyContractTypes), ByVal inDate As Date) As clsAgencyCollection` | Filters agencies by active contract classification. |
| `DirectWriters` | `Public ReadOnly Property DirectWriters() As clsAgencyCollection` | Returns agencies flagged as direct writers. |
| `Expired` | `Public ReadOnly Property Expired() As clsAgencyCollection` | Returns agencies whose appointment has an expiration date recorded. |
| `FederalEmployerID` | `Public ReadOnly Property FederalEmployerID(ByVal inFederalEmployerID As String) As clsAgencyCollection` | Filters the collection down to the agency matching the supplied Federal Employer ID. |
| `NonDirectWriters` | `Public ReadOnly Property NonDirectWriters() As clsAgencyCollection` | Returns agencies that are not direct writers. |
| `NotCommissionHold` | `Public ReadOnly Property NotCommissionHold() As clsAgencyCollection` | Returns agencies whose commission payments are not currently on hold. |
| `NotOnEFTPayment` | `Public ReadOnly Property NotOnEFTPayment() As clsAgencyCollection` | Returns agencies not flagged for electronic funds transfer payment. |
| `OnCommissionHold` | `Public ReadOnly Property OnCommissionHold() As clsAgencyCollection` | Returns agencies with commission-hold status. |
| `OnEFTPayment` | `Public ReadOnly Property OnEFTPayment() As clsAgencyCollection` | Returns agencies flagged for EFT payment. |
| `HasProducerNotExcludedFromListOfValues` | `Public ReadOnly Property HasProducerNotExcludedFromListOfValues() As clsAgencyCollection` | Returns agencies that have at least one producer eligible to appear in list-of-values selection UI. |
| `Producers` | `Public ReadOnly Property Producers() As clsProducerCollection` | Projects the currently loaded producer children from agencies in the collection. |
| `RetrieveProducers` | `Public Sub RetrieveProducers()` | Bulk-loads producer children for every agency already in the collection. |
| `RetrieveContracts` | `Public Sub RetrieveContracts()` | Bulk-loads contract children for every agency already in the collection. |
| `Contains` (agency) | `Public Overloads Function Contains(ByVal inAgency As clsAgency) As Boolean` | Reports whether a specific agency instance is already present. |
| `Contains` (seq num) | `Public Overloads Function Contains(ByVal inAgencySeqNum As Decimal) As Boolean` | Reports whether an agency with the given sequence number is already present. |
| `GetAgencyCollection` (by FEID) | `Public Shared Function GetAgencyCollection(ByVal inDataportal As IDataPortalInfo, ByVal inFederalEmployerID As String) As clsAgencyCollection` | Retrieves all agencies matching a specific Federal Employer ID. |
| `GetAgencyCollection` (all) | `Public Shared Function GetAgencyCollection(ByVal inDataportal As IDataPortalInfo) As clsAgencyCollection` | Retrieves every agency row. |
| `GetAgencyCollection` (by contract types) | `Public Shared Function GetAgencyCollection(ByVal inDataportal As IDataPortalInfo, ByVal inContractTypes As Generic.List(Of clsAgencyContract.AgencyContractTypes)) As clsAgencyCollection` | Retrieves agencies filtered to the supplied set of contract-type classifications. |

## Inherited public members

Members in this section are inherited from `clsBusinessCollectionBase` in `SAIF.Framework.Core`. They are available on this type through inheritance.

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| `First` | `Sub First()` | Moves the collection cursor to the first item.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `Last` | `Sub Last()` | Moves the collection cursor to the last item.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `Next` | `Sub Next()` | Advances the collection cursor.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `Previous` | `Sub Previous()` | Moves the collection cursor backward.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `SetCurrent` | `Sub SetCurrent(item As Object)` | Assigns the current-item position used by BOF traversal helpers.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `Traverse` | `Sub Traverse(inDirection As TraverseDirection)` (via `ITraversion`) | Advances the cursor according to a supplied direction/step.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `Error` | `ReadOnly Property Error As String` (via `IDataErrorInfo`) | Returns a summary validation-error message aggregated across collection items.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `Item(columnName)` | `ReadOnly Property Item(columnName As String) As String` (via `IDataErrorInfo`) | Returns a per-property validation-error message for the collection.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `DeletedCollection` | `Protected Class DeletedCollection` (inherits `CollectionBase`) | Tracks items removed from the collection for inclusion in save/delete operations.* | `SAIF.Framework.Core` — `clsBusinessCollectionBase` |
| `SortDirection` | `ReadOnly Property SortDirection() As ListSortDirection` | Returns the direction of the most recent sort.* | `SAIF.Framework.Core` — `clsSortableCollectionBase` |
| `SortProperty` | `ReadOnly Property SortProperty() As String` | Returns the name of the property the collection is currently sorted by.* | `SAIF.Framework.Core` — `clsSortableCollectionBase` |
| `Sort` / `SortMulti` | `Sub Sort(aProp As String, [aDir As ListSortDirection = Ascending], [stable As StableSortSetting = Default])` / `Sub SortMulti(aParms() As SortParm)` | Sorts the collection by one property, or by multiple properties in sequence using a stable sort.* | `SAIF.Framework.Core` — `clsSortableCollectionBase` |
| `Find` / `FindMulti` / `BinarySearch` | `Function Find(aProp As String, aKey As Object) As Integer` / `Function FindMulti(aParms() As FindParm) As Integer` / `Function BinarySearch(aProp As String, aKey As Object) As Integer` | Locates an item by one or more property/value pairs, or by binary search on an already-sorted collection.* | `SAIF.Framework.Core` — `clsSortableCollectionBase` |
| `Shuffle` | `Sub Shuffle()` | Randomizes item order.* | `SAIF.Framework.Core` — `clsSortableCollectionBase` |
| `RemoveLinks` / `LinkItems` | `Sub RemoveLinks()` / `Sub LinkItems()` | Manages a doubly linked list across `ILinkItem` children so siblings can reference each other.* | `SAIF.Framework.Core` — `clsSortableCollectionBase` |

## Behavioral notes
- Most filter properties iterate the already-loaded collection rather than issuing new SQL.
- `RetrieveProducers()` and `RetrieveContracts()` exist specifically to replace repeated per-agency child queries.

## Constraints and usage notes
- The parameterless retrieval path returns every agency row.
- Child bulk-load helpers silently ignore producer or contract rows whose parent agency is missing from the collection.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `Business\SAIF.Business.Policy.Agency\clsAgencyCollection.vb`
