Class ServiceConfigRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Represents a MongoDB repository for ServiceConfig entities, implementing the IServiceConfigRepository contract to provide data access operations.
public class ServiceConfigRepository : MongoRepository<ServiceConfig>, IServiceConfigRepository, IMongoRepository<ServiceConfig>
- Inheritance
-
ServiceConfigRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
ServiceConfigRepository(IOptions<ApiSettings>, IMongoDatabase)
public ServiceConfigRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)
Parameters
apiSettingsIOptions<ApiSettings>databaseIMongoDatabase
Methods
FindById(ObjectId)
Asynchronously retrieves a ServiceConfig from the collection that matches the specified identifier, returning null when no matching document exists.
public Task<ServiceConfig?> FindById(ObjectId oid)
Parameters
oidObjectIdThe MongoDB.Bson.ObjectId of the ServiceConfig to locate.
Returns
- Task<ServiceConfig>
A ServiceConfig instance if a document with the given identifier is found; otherwise, null.
FindById(string)
Finds a ServiceConfig document by matching its string identifier (StrId) with the provided value.
Returns null when no matching configuration exists in the collection.
public Task<ServiceConfig?> FindById(string id)
Parameters
idstringThe string identifier used to look up the service configuration.
Returns
- Task<ServiceConfig>
A task that represents the asynchronous operation, containing the matching ServiceConfig or
nullif not found.
GetCollectionName()
Retrieves the service configuration collection name from API settings, falling back to the default "service_config" when no value is configured.
public override string GetCollectionName()
Returns
- string
The configured service collection name, or the default "service_config" when the API setting is null.