Class DatabaseOptions
- Namespace
- Tharga.MongoDB.Configuration
- Assembly
- Tharga.MongoDB.dll
All database options are optional.
public record DatabaseOptions : IEquatable<DatabaseOptions>
- Inheritance
-
DatabaseOptions
- Implements
- Inherited Members
Properties
ActionEvent
Event triggered on database actions performed on disk.
public Action<ActionEventArgs> ActionEvent { get; set; }
Property Value
AllowDelayedCommit
Controls whether CommitAsync(bool, CancellationToken) may succeed for
a lease whose lock has expired, provided no other writer has touched the document since
(the LockKey atomicity check still drives the safety guarantee). Default true.
Set to false to restore the strict-TTL behaviour where every expired commit throws
LockExpiredException. Individual collections can pin themselves to
either policy by overriding the virtual AllowDelayedCommit property on
LockableRepositoryCollectionBase<TEntity, TKey>.
public bool AllowDelayedCommit { get; set; }
Property Value
AssureIndex
Enable or disable the assurance of incexes. By default, indexes are assured.
public AssureIndexMode AssureIndex { get; set; }
Property Value
AutoRegisterCollections
If true, all classes inheriting from IRepositoryCollection will be registered. This value is default true. Use 'RegisterCollections' in 'DatabaseOptions' to register repositories manually.
public bool AutoRegisterCollections { get; set; }
Property Value
AutoRegisterRepositories
If true, all classes inheriting from IRepository will be registered. This value is default true. Use IServiceCollection to register repositories manually.
public bool AutoRegisterRepositories { get; set; }
Property Value
AutoRegistrationAssemblies
Override the list of assemblies scanned for automatic registration of IRepository and IRepositoryCollection. By default, only assemblies whose name starts with the same prefix as the entry-point assembly are scanned. Assemblies from external NuGet packages are NOT included by default — use AddAutoRegistrationAssembly(Assembly) to add them without replacing the default scan.
public IEnumerable<Assembly> AutoRegistrationAssemblies { get; set; }
Property Value
ConfigurationLoader
When provided this will override values in appsettings.json. Values in 'Configurations' will be used if they exist, otherwise the values in root will be used. Configuration order:
- Named values from Configurations.
- Values from the root in Configuration.
- Named values from MongoDB-section in appsettings.json.
- Values from the root in MongoDB-section in appsettings.json.
- Default values.
public Func<IServiceProvider, Task<MongoDbConfigurationTree>> ConfigurationLoader { get; set; }
Property Value
ConnectionStringLoader
This function can be provided to dynamically provide a connection string for a specific configuration. If it is not assigned or returns null, the configuration will be read from IConfiguration.
public Func<ConfigurationName, IServiceProvider, Task<ConnectionString>> ConnectionStringLoader { get; set; }
Property Value
DefaultConfigurationName
The name of the connection string that will be used to read from appsettings.json or from ConnectionStringLoader. If not provided 'Default' will be used.
public string DefaultConfigurationName { get; set; }
Property Value
GuidStorageFormat
Controls how Guid values are stored in MongoDB. Standard (RFC 4122) is the default. Use CSharpLegacy only when working with existing legacy data. Individual properties can override this with [FlexibleGuid(GuidStorageFormat.X)].
public GuidStorageFormat GuidStorageFormat { get; set; }
Property Value
Limiter
Configure database execution limiter.
public ExecuteLimiterOptions Limiter { get; set; }
Property Value
Monitor
Configuration for monitor. This is by default enabled.
public MonitorOptions Monitor { get; set; }
Property Value
ReadyCallback
Optional callback that defers the monitor cache load until the system is ready. When set, the monitor starts immediately (API is usable) but the cache load is postponed until the provided callback action is invoked. The cache is loaded at most once, even if the callback is invoked multiple times. Example usage:
o.ReadyCallback = (serviceProvider, onReady) =>
{
var config = serviceProvider.GetService<IMyConfig>();
config.ConfigurationUpdatedEvent += async (_, _) =>
{
if (config.HasConfiguration) await onReady();
};
};
public Action<IServiceProvider, Func<Task>> ReadyCallback { get; set; }
Property Value
RegisterCollections
Provide manual registration of collections.
public IEnumerable<CollectionType> RegisterCollections { get; set; }
Property Value
Methods
AddAutoRegistrationAssembly(Assembly)
Add additional assemblies for auto registration of IRepository and IRepositoryCollection.
public void AddAutoRegistrationAssembly(Assembly assembly)
Parameters
assemblyAssembly