Table of Contents

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

database IMongoDatabase
apiSettings IOptions<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

relayId ObjectId

The unique identifier of the relay to look up.

Returns

Task<Relay>

The matching Relay, or null if no document matches the identifier or the query fails.

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

requestRelayName string

The 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 null if 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

filter PaginationFilter

The 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

configurationRelayList List<ObjectId>

The collection of relay identifiers used to filter relays by their Id field.

type RelayEnum.Type

The 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

configurationRelayList List<ObjectId>

The collection of MongoDB.Bson.ObjectId values used to match relays by their Id field.

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

request Relay

The relay entity to insert into the collection.

Returns

Task<Relay>

The inserted relay retrieved by its identifier, or null if the insertion fails.

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

objectId ObjectId

The unique identifier of the relay document to update in the collection.

relay Relay

The relay instance containing the new values to apply to the existing document.

Returns

Task<Relay>

A task that represents the asynchronous operation, containing the updated Relay after the update, or null if no matching document was found.