Class RelayRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Represents a repository for managing Relay entities, providing MongoDB-backed data access through the MongoRepository<T> base class and exposing the contract defined by IRelayRepository.
public class RelayRepository : MongoRepository<Relay>, IRelayRepository, IMongoRepository<Relay>
- Inheritance
-
RelayRepository
- Implements
- Inherited Members
- Extension Methods
Remarks
This class combines a concrete MongoDB repository implementation with a domain-specific interface, enabling standardized persistence operations for relay entities.
Constructors
RelayRepository(IMongoDatabase, IOptions<ApiSettings>)
public RelayRepository(IMongoDatabase database, IOptions<ApiSettings> apiSettings)
Parameters
databaseIMongoDatabaseapiSettingsIOptions<ApiSettings>
Methods
GetById(ObjectId)
Retrieves a Relay from the collection by its identifier, returning the first match or null when no document is found or an error occurs while querying.
public Task<Relay?> GetById(ObjectId relayId)
Parameters
relayIdObjectIdThe unique identifier of the relay to look up.
Returns
GetByName(string?)
Retrieves a Relay from the collection whose RelayName matches the specified name.
Returns null when no relay with the given name exists in the collection.
public Task<Relay?> GetByName(string? requestRelayName)
Parameters
requestRelayNamestringThe name of the relay to look up. May be
null, in which case the query matches relays with a null name.
Returns
- Task<Relay>
A Task<TResult> containing the matching Relay, or
nullif no relay with the specified name is found.
GetCollectionName()
Retrieves the collection name for relays from the API settings configuration.
public override string GetCollectionName()
Returns
- string
The configured relays collection name as specified in the API settings.
GetPaginatedRelays(PaginationFilter)
Retrieves a paginated, sortable set of relays, optionally filtered by a case-insensitive text match on the relay name. When the filter's text is null or empty, no text-based criteria are applied and the result is returned with the default ascending sort by relay name.
public IFindFluent<Relay, Relay> GetPaginatedRelays(PaginationFilter filter)
Parameters
filterPaginationFilterThe pagination criteria containing the optional text filter applied against the relay name.
Returns
- IFindFluent<Relay, Relay>
A fluent find query for Relay entities, ordered by relay name in ascending order, ready for further pagination.
GetRelayByTypeInList(List<ObjectId>, Type)
Retrieves a list of relays from the collection whose identifiers are contained in the provided configuration list and whose type matches the specified value.
public List<Relay> GetRelayByTypeInList(List<ObjectId> configurationRelayList, RelayEnum.Type type)
Parameters
configurationRelayListList<ObjectId>The collection of relay identifiers used to filter relays by their Id field.
typeRelayEnum.TypeThe relay type used as an equality filter on the Type field.
Returns
- List<Relay>
A list of Relay instances matching both the identifier and type filters; an empty list is returned when no relays match.
GetRelayInList(List<ObjectId>)
Retrieves the Relay entries whose identifiers are contained in the supplied list, returning all matches as a list.
public List<Relay> GetRelayInList(List<ObjectId> configurationRelayList)
Parameters
configurationRelayListList<ObjectId>The collection of MongoDB.Bson.ObjectId values used to match relays by their
Idfield.
Returns
- List<Relay>
A List<T> containing the relays whose identifiers are found in
configurationRelayList; an empty list is returned when no matching relays exist.
InsertOneRelayAsync(Relay)
Asynchronously inserts a new relay into the collection and returns the persisted entity fetched by its identifier.
On failure, the exception is logged and the method returns null instead of propagating the error.
public Task<Relay?> InsertOneRelayAsync(Relay request)
Parameters
requestRelayThe relay entity to insert into the collection.
Returns
UpdateRelayAsync(ObjectId, Relay)
Updates an existing relay document identified by the specified object identifier with the provided relay data and returns the updated entity.
public Task<Relay?> UpdateRelayAsync(ObjectId objectId, Relay relay)
Parameters
objectIdObjectIdThe unique identifier of the relay document to update in the collection.
relayRelayThe relay instance containing the new values to apply to the existing document.