Skip to content

ProvidersRepository

ProvidersRepository is the only repository in this library that is a plain class rather than a Repository<T>/RepositoryBase<T> subclass: it wraps a generic IUnitOfWork and calls unitOfWork.GetRepository<T>() per-entity-type instead of being bound to a single mapped entity. It offers provider lookup by tax id and address lookup filtered by address type, with GetProviderPaymentAddresses/GetProviderPhysicalAddresses hard-coding the "PAY"/"PHY" address-type codes (SDN-BR-031).

Purpose

  • Look up a Provider by its primary tax id for batch processing scenarios.
  • Return active (non-expired) provider addresses filtered by address type, with dedicated payment ("PAY") and physical ("PHY") address helpers (SDN-BR-031).
  • Enforce that a non-null IUnitOfWork is supplied at construction, per SDN-BR-030.

Context

  • Namespace: SAIF.Data.NHibernate.Repositories
  • Assembly/package: SAIF.Data.NHibernate (ships inside the SAIF.SAIFCode.Core NuGet package)
  • No base class: ProvidersRepository is a plain class, not a Repository<T>/RepositoryBase<T> subclass; it holds a private IUnitOfWork field and calls unitOfWork.GetRepository<T>() per query.
  • IUnitOfWork is defined in SAIF.Framework.Data.NHibernate (external); its concrete implementation, NHibernateUnitOfWork, exposes GetRepository<TEntity>() : Repository<TEntity> which constructs a new Repository<TEntity> bound to the same session/transaction (resolved via Legends CLI)†.

Public members

Member Signature Purpose
ProvidersRepository(IUnitOfWork) public ProvidersRepository(IUnitOfWork uow) Constructor; validates uow is non-null via Enforce.ArgumentNotNull (SAIF.Framework.Core), throwing if null, then stores it (SDN-BR-030).
GetProviderByTaxIdBatch public Provider GetProviderByTaxIdBatch(string taxId) Returns the single Provider whose PrimaryTaxId equals taxId via unitOfWork.GetRepository<Provider>().Query().SingleOrDefault(), or null if none/ambiguous match throws (SQL-048).
GetProviderAddresses public IEnumerable<ProviderAddress> GetProviderAddresses(long providerId, string addressType) Returns non-expired ProviderAddress rows for the given provider id and address-type code, materialized to a list, via unitOfWork.GetRepository<ProviderAddress>().Query() (SQL-049).
GetProviderPaymentAddresses public IEnumerable<ProviderAddress> GetProviderPaymentAddresses(long providerId) Calls GetProviderAddresses(providerId, "PAY") to return the provider's payment addresses (SDN-BR-031).
GetProviderPhysicalAddresses public IEnumerable<ProviderAddress> GetProviderPhysicalAddresses(long providerId) Calls GetProviderAddresses(providerId, "PHY") to return the provider's physical addresses (SDN-BR-031).

Behavioral notes

  • GetProviderAddresses filters on pa.ExpirationDate == null (address currently active) in addition to ProviderLocation.Provider.Id == providerId and AddressType.Code == addressType*.
  • Because this class does not derive from Repository<T>, it has no CRUD surface of its own; all persistence access goes through per-call IUnitOfWork.GetRepository<TEntity>() calls, meaning each query obtains a fresh Repository<TEntity> bound to the same underlying session/transaction as the injected unit of work†.

Constraints and usage notes

  • The constructor throws (via Enforce.ArgumentNotNull) if uow is null; callers must supply a valid IUnitOfWork instance (SDN-BR-030).
  • GetProviderByTaxIdBatch uses SingleOrDefault, which throws InvalidOperationException if more than one Provider shares the same PrimaryTaxId*.

Note: Statements marked with † are derived from dependency library documentation via the Legends CLI. Statements marked with * were inferred from code structure or contextual evidence. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • Data/SAIF.Data.NHibernate/Repositories/ProvidersRepository.cs