Class RedbServiceBase
Base abstract class for RedbService implementations.
Contains all common logic for delegating to providers.
Provider-specific implementations (Postgres, MSSQL) inherit from this class.
public abstract class RedbServiceBase : IRedbService, ISchemeSyncProvider, IObjectStorageProvider, ITreeProvider, IPermissionProvider, IQueryableProvider, IValidationProvider
Inheritance
Implements
Derived
Properties
ContextNotRegisteredError
Error message when IRedbContext is not registered.
protected abstract string ContextNotRegisteredError { get; }
DatabaseTypeName
Database provider name (e.g., "PostgreSQL", "MSSql").
protected abstract string DatabaseTypeName { get; }
dbVersion
public string dbVersion { get; }
GetDatabaseSizeSql
SQL query to get database size in bytes.
protected abstract string GetDatabaseSizeSql { get; }
PropsCache
Domain-bound props/object cache for this provider.
public GlobalPropsCache PropsCache { get; }
SecurityContext
Security context for user and permission management.
public IRedbSecurityContext SecurityContext { get; }
SqlDialect
SQL dialect for database-specific queries.
protected abstract ISqlDialect SqlDialect { get; }
Methods
AddNewObjectsAsync<TProps>(IEnumerable<IRedbObject<TProps>>, IRedbUser)
BULK INSERT with explicit user: Create many new objects (does NOT check permissions).
public Task<List<long>> AddNewObjectsAsync<TProps>(IEnumerable<IRedbObject<TProps>> objects, IRedbUser user) where TProps : class, new()
AddNewObjectsAsync<TProps>(IEnumerable<IRedbObject<TProps>>)
BULK INSERT: Create many new objects in one operation (does NOT check permissions).
public Task<List<long>> AddNewObjectsAsync<TProps>(IEnumerable<IRedbObject<TProps>> objects) where TProps : class, new()
AnalyzeSchemaChangesAsync<TProps>(IRedbScheme)
Check schema change compatibility.
public Task<SchemaChangeReport> AnalyzeSchemaChangesAsync<TProps>(IRedbScheme scheme) where TProps : class
CanUserDeleteObject(IRedbObject, IRedbUser)
Check if user can delete object.
public Task<bool> CanUserDeleteObject(IRedbObject obj, IRedbUser user)
CanUserDeleteObject(IRedbObject)
Check if current user can delete object.
public Task<bool> CanUserDeleteObject(IRedbObject obj)
CanUserDeleteObject(long, long)
public Task<bool> CanUserDeleteObject(long objectId, long userId)
CanUserDeleteObject(RedbObject, IRedbUser)
Check if user can delete object.
public Task<bool> CanUserDeleteObject(RedbObject obj, IRedbUser user)
CanUserDeleteObject(RedbObject)
Check if current user can delete object.
public Task<bool> CanUserDeleteObject(RedbObject obj)
CanUserEditObject(IRedbObject, IRedbUser)
Check if user can edit object.
public Task<bool> CanUserEditObject(IRedbObject obj, IRedbUser user)
CanUserEditObject(IRedbObject)
Check if current user can edit object.
public Task<bool> CanUserEditObject(IRedbObject obj)
CanUserEditObject(long, long)
public Task<bool> CanUserEditObject(long objectId, long userId)
CanUserEditObject(RedbObject, IRedbUser)
Check if user can edit object.
public Task<bool> CanUserEditObject(RedbObject obj, IRedbUser user)
CanUserEditObject(RedbObject)
Check if current user can edit object.
public Task<bool> CanUserEditObject(RedbObject obj)
CanUserInsertScheme(IRedbScheme, IRedbUser)
Check if user can create objects in scheme.
public Task<bool> CanUserInsertScheme(IRedbScheme scheme, IRedbUser user)
CanUserInsertScheme(IRedbScheme)
Check if current user can create objects in scheme.
public Task<bool> CanUserInsertScheme(IRedbScheme scheme)
CanUserInsertScheme(long, long)
public Task<bool> CanUserInsertScheme(long schemeId, long userId)
CanUserInsertScheme(RedbObject, IRedbUser)
Check if user can create objects in object's scheme.
public Task<bool> CanUserInsertScheme(RedbObject obj, IRedbUser user)
CanUserSelectObject(IRedbObject, IRedbUser)
Check if user can read object.
public Task<bool> CanUserSelectObject(IRedbObject obj, IRedbUser user)
CanUserSelectObject(IRedbObject)
Check if current user can read object.
public Task<bool> CanUserSelectObject(IRedbObject obj)
CanUserSelectObject(long, long)
public Task<bool> CanUserSelectObject(long objectId, long userId)
CanUserSelectObject(RedbObject, IRedbUser)
Check if user can read object.
public Task<bool> CanUserSelectObject(RedbObject obj, IRedbUser user)
CanUserSelectObject(RedbObject)
Check if current user can read object.
public Task<bool> CanUserSelectObject(RedbObject obj)
CreateChildAsync<TProps>(TreeRedbObject<TProps>, IRedbObject, IRedbUser)
Create child object with explicit user (uses config.DefaultCheckPermissionsOnSave).
public Task<long> CreateChildAsync<TProps>(TreeRedbObject<TProps> obj, IRedbObject parentObj, IRedbUser user) where TProps : class, new()
CreateChildAsync<TProps>(TreeRedbObject<TProps>, IRedbObject)
Create child object (uses _securityContext and config.DefaultCheckPermissionsOnSave).
public Task<long> CreateChildAsync<TProps>(TreeRedbObject<TProps> obj, IRedbObject parentObj) where TProps : class, new()
CreateLazyPropsLoader(IRedbContext, ISchemeSyncProvider, IRedbObjectSerializer, RedbServiceConfiguration, string, IListProvider, ILogger?)
Create lazy props loader.
protected abstract ILazyPropsLoader CreateLazyPropsLoader(IRedbContext context, ISchemeSyncProvider schemeSync, IRedbObjectSerializer serializer, RedbServiceConfiguration config, string cacheDomain, IListProvider listProvider, ILogger? logger)
CreateListProvider(IRedbContext, RedbServiceConfiguration, ISchemeSyncProvider, ILogger?)
Create list provider.
protected abstract IListProvider CreateListProvider(IRedbContext context, RedbServiceConfiguration config, ISchemeSyncProvider schemeSync, ILogger? logger)
CreateObjectStorageProvider(IRedbContext, IRedbObjectSerializer, IPermissionProvider, IRedbSecurityContext, ISchemeSyncProvider, RedbServiceConfiguration, IListProvider, ILogger?)
Create object storage provider.
protected abstract IObjectStorageProvider CreateObjectStorageProvider(IRedbContext context, IRedbObjectSerializer serializer, IPermissionProvider permissionProvider, IRedbSecurityContext securityContext, ISchemeSyncProvider schemeSync, RedbServiceConfiguration config, IListProvider listProvider, ILogger? logger)
CreatePermissionAsync(PermissionRequest, IRedbUser?)
Create new permission.
public Task<IRedbPermission> CreatePermissionAsync(PermissionRequest request, IRedbUser? currentUser = null)
CreatePermissionProvider(IRedbContext, IRedbSecurityContext, ILogger?)
Create permission provider.
protected abstract IPermissionProvider CreatePermissionProvider(IRedbContext context, IRedbSecurityContext securityContext, ILogger? logger)
CreateQueryableProvider(IRedbContext, IRedbObjectSerializer, ISchemeSyncProvider, IRedbSecurityContext, ILazyPropsLoader, RedbServiceConfiguration, string, ILogger?)
Create queryable provider.
protected abstract IQueryableProvider CreateQueryableProvider(IRedbContext context, IRedbObjectSerializer serializer, ISchemeSyncProvider schemeSync, IRedbSecurityContext securityContext, ILazyPropsLoader lazyPropsLoader, RedbServiceConfiguration config, string cacheDomain, ILogger? logger)
CreateRoleProvider(IRedbContext, IRedbSecurityContext, ILogger?)
Create role provider.
protected abstract IRoleProvider CreateRoleProvider(IRedbContext context, IRedbSecurityContext securityContext, ILogger? logger)
CreateSchemeSyncProvider(IRedbContext, RedbServiceConfiguration, string, ILogger?)
Create scheme sync provider.
protected abstract ISchemeSyncProvider CreateSchemeSyncProvider(IRedbContext context, RedbServiceConfiguration config, string cacheDomain, ILogger? logger)
CreateTreeProvider(IRedbContext, IObjectStorageProvider, IPermissionProvider, IRedbObjectSerializer, IRedbSecurityContext, ISchemeSyncProvider, RedbServiceConfiguration, ILogger?)
Create tree provider.
protected abstract ITreeProvider CreateTreeProvider(IRedbContext context, IObjectStorageProvider objectStorage, IPermissionProvider permissionProvider, IRedbObjectSerializer serializer, IRedbSecurityContext securityContext, ISchemeSyncProvider schemeSync, RedbServiceConfiguration config, ILogger? logger)
CreateUserProvider(IRedbContext, IRedbSecurityContext, ILogger?)
Create user provider.
protected abstract IUserProvider CreateUserProvider(IRedbContext context, IRedbSecurityContext securityContext, ILogger? logger)
CreateValidationProvider(IRedbContext, ILogger?)
Create validation provider.
protected abstract IValidationProvider CreateValidationProvider(IRedbContext context, ILogger? logger)
DeleteAsync(IEnumerable<IRedbObject>, IRedbUser)
Bulk delete objects by interface with explicit user (uses config.DefaultCheckPermissionsOnDelete).
public Task<int> DeleteAsync(IEnumerable<IRedbObject> objects, IRedbUser user)
DeleteAsync(IEnumerable<IRedbObject>)
Bulk delete objects by interface (uses _securityContext and config.DefaultCheckPermissionsOnDelete).
public Task<int> DeleteAsync(IEnumerable<IRedbObject> objects)
DeleteAsync(IEnumerable<long>, IRedbUser)
Bulk delete objects by ID with explicit user (uses config.DefaultCheckPermissionsOnDelete).
public Task<int> DeleteAsync(IEnumerable<long> objectIds, IRedbUser user)
DeleteAsync(IEnumerable<long>)
Bulk delete objects by ID (uses _securityContext and config.DefaultCheckPermissionsOnDelete).
public Task<int> DeleteAsync(IEnumerable<long> objectIds)
DeleteAsync(IRedbObject, IRedbUser)
Delete object with explicit user (uses config.DefaultCheckPermissionsOnDelete).
public Task<bool> DeleteAsync(IRedbObject obj, IRedbUser user)
DeleteAsync(IRedbObject)
Delete object (uses _securityContext and config.DefaultCheckPermissionsOnDelete).
public Task<bool> DeleteAsync(IRedbObject obj)
DeleteAsync(long, IRedbUser)
Delete object by ID with explicit user (uses config.DefaultCheckPermissionsOnDelete).
public Task<bool> DeleteAsync(long objectId, IRedbUser user)
DeleteAsync(long)
Delete object by ID (uses _securityContext and config.DefaultCheckPermissionsOnDelete).
public Task<bool> DeleteAsync(long objectId)
DeletePermissionAsync(IRedbPermission, IRedbUser?)
Delete permission.
public Task<bool> DeletePermissionAsync(IRedbPermission permission, IRedbUser? currentUser = null)
DeleteSubtreeAsync(IRedbObject, IRedbUser)
Delete object subtree recursively with explicit user (uses config.DefaultCheckPermissionsOnDelete).
public Task<int> DeleteSubtreeAsync(IRedbObject parentObj, IRedbUser user)
DeleteSubtreeAsync(IRedbObject)
Delete object subtree recursively (uses _securityContext and config.DefaultCheckPermissionsOnDelete).
public Task<int> DeleteSubtreeAsync(IRedbObject parentObj)
DeleteSubtreeAsync(RedbObject, IRedbUser)
public Task<int> DeleteSubtreeAsync(RedbObject parentObj, IRedbUser user)
DeleteSubtreeAsync(RedbObject)
public Task<int> DeleteSubtreeAsync(RedbObject parentObj)
DeleteWithPurgeAsync(IEnumerable<long>, int, IProgress<PurgeProgress>?, CancellationToken, long?)
Delete objects with background purge and progress reporting.
public Task DeleteWithPurgeAsync(IEnumerable<long> objectIds, int batchSize = 10, IProgress<PurgeProgress>? progress = null, CancellationToken cancellationToken = default, long? trashParentId = null)
EnsureDatabaseAsync()
Ensures the REDB database schema exists.
public virtual Task EnsureDatabaseAsync()
EnsureObjectSchemeAsync(string)
Get or create scheme for Object type (without Props).
public Task<IRedbScheme> EnsureObjectSchemeAsync(string name)
EnsureSchemeFromTypeAsync<TProps>()
Create/get scheme by name from Props type.
public Task<IRedbScheme> EnsureSchemeFromTypeAsync<TProps>() where TProps : class
ExecuteSchemaScriptAsync(string)
Executes the full schema initialization SQL script against the database.
protected abstract Task ExecuteSchemaScriptAsync(string sql)
GetAllEffectivePermissionsAsync(IRedbUser)
Get all effective user permissions.
public Task<List<EffectivePermissionResult>> GetAllEffectivePermissionsAsync(IRedbUser user)
GetChildrenAsync<TProps>(IRedbObject, IRedbUser)
Get direct children of object with explicit user (uses config.DefaultCheckPermissionsOnLoad).
public Task<IEnumerable<TreeRedbObject<TProps>>> GetChildrenAsync<TProps>(IRedbObject parentObj, IRedbUser user) where TProps : class, new()
GetChildrenAsync<TProps>(IRedbObject)
Get direct children of object (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<IEnumerable<TreeRedbObject<TProps>>> GetChildrenAsync<TProps>(IRedbObject parentObj) where TProps : class, new()
GetDeletionProgressAsync(long)
Gets deletion progress for a specific trash container from database.
public Task<PurgeProgress?> GetDeletionProgressAsync(long trashId)
GetDescendantsAsync<TProps>(IRedbObject, int?)
Get all object descendants (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<IEnumerable<TreeRedbObject<TProps>>> GetDescendantsAsync<TProps>(IRedbObject parentObj, int? maxDepth = null) where TProps : class, new()
GetDescendantsAsync<TProps>(IRedbObject, IRedbUser, int?)
Get all object descendants with explicit user (uses config.DefaultCheckPermissionsOnLoad).
public Task<IEnumerable<TreeRedbObject<TProps>>> GetDescendantsAsync<TProps>(IRedbObject parentObj, IRedbUser user, int? maxDepth = null) where TProps : class, new()
GetEffectivePermissionsAsync(IRedbUser, IRedbObject)
Get effective user permissions for object (including inheritance and roles).
public Task<EffectivePermissionResult> GetEffectivePermissionsAsync(IRedbUser user, IRedbObject obj)
GetEffectivePermissionsBatchAsync(IRedbUser, IRedbObject[])
Get effective user permissions for multiple objects (batch).
public Task<Dictionary<IRedbObject, EffectivePermissionResult>> GetEffectivePermissionsBatchAsync(IRedbUser user, IRedbObject[] objects)
GetObjectJsonSql()
Get SQL for loading object as JSON. Override in derived classes for DB-specific syntax.
protected virtual string GetObjectJsonSql()
GetObjectSchemeAsync(string)
Get scheme for Object type by name.
public Task<IRedbScheme?> GetObjectSchemeAsync(string name)
GetOrphanedDeletionTasksAsync(int)
Gets orphaned deletion tasks for recovery at startup.
public Task<List<OrphanedTask>> GetOrphanedDeletionTasksAsync(int timeoutMinutes = 30)
GetPathToRootAsync<TProps>(IRedbObject, IRedbUser)
Get path from object to root with explicit user (uses config.DefaultCheckPermissionsOnLoad).
public Task<IEnumerable<TreeRedbObject<TProps>>> GetPathToRootAsync<TProps>(IRedbObject obj, IRedbUser user) where TProps : class, new()
GetPathToRootAsync<TProps>(IRedbObject)
Get path from object to root (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<IEnumerable<TreeRedbObject<TProps>>> GetPathToRootAsync<TProps>(IRedbObject obj) where TProps : class, new()
GetPermissionByIdAsync(long)
Get permission by ID.
public Task<IRedbPermission?> GetPermissionByIdAsync(long permissionId)
GetPermissionsByObjectAsync(IRedbObject)
Get permissions for object.
public Task<List<IRedbPermission>> GetPermissionsByObjectAsync(IRedbObject obj)
GetPermissionsByRoleAsync(IRedbRole)
Get role permissions.
public Task<List<IRedbPermission>> GetPermissionsByRoleAsync(IRedbRole role)
GetPermissionsByUserAsync(IRedbUser)
Get user permissions.
public Task<List<IRedbPermission>> GetPermissionsByUserAsync(IRedbUser user)
GetPolymorphicChildrenAsync(IRedbObject, IRedbUser)
Get all direct children of object regardless of their schemes with explicit user.
public Task<IEnumerable<ITreeRedbObject>> GetPolymorphicChildrenAsync(IRedbObject parentObj, IRedbUser user)
GetPolymorphicChildrenAsync(IRedbObject)
Get all direct children of object regardless of their schemes.
public Task<IEnumerable<ITreeRedbObject>> GetPolymorphicChildrenAsync(IRedbObject parentObj)
GetPolymorphicDescendantsAsync(IRedbObject, int?)
Get all polymorphic descendants of object regardless of their schemes.
public Task<IEnumerable<ITreeRedbObject>> GetPolymorphicDescendantsAsync(IRedbObject parentObj, int? maxDepth = null)
GetPolymorphicDescendantsAsync(IRedbObject, IRedbUser, int?)
Get all polymorphic descendants of object with explicit user.
public Task<IEnumerable<ITreeRedbObject>> GetPolymorphicDescendantsAsync(IRedbObject parentObj, IRedbUser user, int? maxDepth = null)
GetPolymorphicPathToRootAsync(IRedbObject, IRedbUser)
Get polymorphic path from object to root with explicit user.
public Task<IEnumerable<ITreeRedbObject>> GetPolymorphicPathToRootAsync(IRedbObject obj, IRedbUser user)
GetPolymorphicPathToRootAsync(IRedbObject)
Get polymorphic path from object to root - objects can be of different schemes.
public Task<IEnumerable<ITreeRedbObject>> GetPolymorphicPathToRootAsync(IRedbObject obj)
GetReadableObjectIds()
Get IDs of objects readable by current user.
public IQueryable<long> GetReadableObjectIds()
GetReadableObjectIds(IRedbUser)
Get IDs of objects readable by user.
public IQueryable<long> GetReadableObjectIds(IRedbUser user)
GetRolePermissionCountAsync(IRedbRole)
Get role permission count.
public Task<int> GetRolePermissionCountAsync(IRedbRole role)
GetSchemaScript()
Returns the full SQL script that creates the REDB schema.
public string GetSchemaScript()
GetSchemeAliasForType(Type)
Get scheme alias for C# class type.
public string? GetSchemeAliasForType(Type type)
GetSchemeAliasForType<TProps>()
Get scheme alias for C# class type.
public string? GetSchemeAliasForType<TProps>() where TProps : class
GetSchemeByIdAsync(long)
Get scheme by ID.
public Task<IRedbScheme?> GetSchemeByIdAsync(long schemeId)
GetSchemeByNameAsync(string)
Get scheme by name.
public Task<IRedbScheme?> GetSchemeByNameAsync(string schemeName)
GetSchemeByTypeAsync(Type)
Get scheme by C# class type.
public Task<IRedbScheme?> GetSchemeByTypeAsync(Type type)
GetSchemeByTypeAsync<TProps>()
Get scheme by C# class type.
public Task<IRedbScheme?> GetSchemeByTypeAsync<TProps>() where TProps : class
GetSchemeFromCache(string)
Get scheme from cache synchronously (no DB call).
public IRedbScheme? GetSchemeFromCache(string schemeName)
GetSchemeFromCache<TProps>()
Get scheme from cache synchronously (no DB call).
public IRedbScheme? GetSchemeFromCache<TProps>() where TProps : class
GetSchemeNameForType(Type)
Get scheme name for C# class type.
public string GetSchemeNameForType(Type type)
GetSchemeNameForType<TProps>()
Get scheme name for C# class type.
public string GetSchemeNameForType<TProps>() where TProps : class
GetStructuresAsync(IRedbScheme)
Get scheme structures.
public Task<List<IRedbStructure>> GetStructuresAsync(IRedbScheme scheme)
GetStructuresByTypeAsync(Type)
Get scheme structures by C# class type.
public Task<List<IRedbStructure>> GetStructuresByTypeAsync(Type type)
GetStructuresByTypeAsync<TProps>()
Get scheme structures by C# class type.
public Task<List<IRedbStructure>> GetStructuresByTypeAsync<TProps>() where TProps : class
GetStructureTreeAsync(long)
Get structure tree for scheme (cached).
public Task<List<StructureTreeNode>> GetStructureTreeAsync(long schemeId)
GetStructureTreeCacheStats()
Get structure tree cache statistics.
public (int TreesCount, int SubtreesCount, long MemoryEstimate) GetStructureTreeCacheStats()
GetSubtreeAsync(long, long?)
Get subtree starting from parent structure (cached).
public Task<List<StructureTreeNode>> GetSubtreeAsync(long schemeId, long? parentStructureId)
GetSupportedTypesAsync()
Get all supported types.
public Task<List<SupportedType>> GetSupportedTypesAsync()
GetUserActiveDeletionsAsync(long)
Gets all active (pending/running) deletions for a user from database.
public Task<List<PurgeProgress>> GetUserActiveDeletionsAsync(long userId)
GetUserPermissionCountAsync(IRedbUser)
Get user permission count.
public Task<int> GetUserPermissionCountAsync(IRedbUser user)
GrantPermissionAsync(IRedbRole, IRedbObject, PermissionAction, IRedbUser?)
Grant permission to role.
public Task<bool> GrantPermissionAsync(IRedbRole role, IRedbObject obj, PermissionAction actions, IRedbUser? currentUser = null)
GrantPermissionAsync(IRedbUser, IRedbObject, PermissionAction, IRedbUser?)
Grant permission to user.
public Task<bool> GrantPermissionAsync(IRedbUser user, IRedbObject obj, PermissionAction actions, IRedbUser? currentUser = null)
InitializeAsync(bool, params Assembly[])
Initialize REDB system at application startup, optionally creating the database schema first.
public Task InitializeAsync(bool ensureCreated, params Assembly[] assemblies)
InitializeAsync(params Assembly[])
Initialize REDB system at application startup.
public Task InitializeAsync(params Assembly[] assemblies)
InitializeTypeRegistryAsync()
Initialize AutomaticTypeRegistry for polymorphic operation support.
public Task InitializeTypeRegistryAsync()
InvalidateStructureTreeCache(long)
Invalidate structure tree cache for scheme.
public void InvalidateStructureTreeCache(long schemeId)
LoadAsync(IEnumerable<long>, int, bool?)
Bulk polymorphic load of objects by ID (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<List<IRedbObject>> LoadAsync(IEnumerable<long> objectIds, int depth = 10, bool? lazyLoadProps = null)
LoadAsync(IEnumerable<long>, IRedbUser, int, bool?)
Bulk polymorphic load of objects by ID with explicit user (uses config.DefaultCheckPermissionsOnLoad).
public Task<List<IRedbObject>> LoadAsync(IEnumerable<long> objectIds, IRedbUser user, int depth = 10, bool? lazyLoadProps = null)
LoadAsync<TProps>(IRedbObject, int, bool?)
Load object from EAV (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<RedbObject<TProps>?> LoadAsync<TProps>(IRedbObject obj, int depth = 10, bool? lazyLoadProps = null) where TProps : class, new()
LoadAsync<TProps>(IRedbObject, IRedbUser, int, bool?)
Load object from EAV with explicit user (uses config.DefaultCheckPermissionsOnLoad).
public Task<RedbObject<TProps>?> LoadAsync<TProps>(IRedbObject obj, IRedbUser user, int depth = 10, bool? lazyLoadProps = null) where TProps : class, new()
LoadAsync<TProps>(long, int, bool?)
Load object from EAV by ID (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<RedbObject<TProps>?> LoadAsync<TProps>(long objectId, int depth = 10, bool? lazyLoadProps = null) where TProps : class, new()
LoadAsync<TProps>(long, IRedbUser, int, bool?)
Load object from EAV with explicit user by ID (uses config.DefaultCheckPermissionsOnLoad).
public Task<RedbObject<TProps>?> LoadAsync<TProps>(long objectId, IRedbUser user, int depth = 10, bool? lazyLoadProps = null) where TProps : class, new()
LoadPolymorphicTreeAsync(IRedbObject, int?)
Load polymorphic tree/subtree - supports objects of different schemes in one tree.
public Task<ITreeRedbObject> LoadPolymorphicTreeAsync(IRedbObject rootObj, int? maxDepth = null)
LoadPolymorphicTreeAsync(IRedbObject, IRedbUser, int?)
Load polymorphic tree/subtree with explicit user.
public Task<ITreeRedbObject> LoadPolymorphicTreeAsync(IRedbObject rootObj, IRedbUser user, int? maxDepth = null)
LoadSchemeByTypeAsync(Type)
Load scheme by C# class type (throws exception if not found).
public Task<IRedbScheme> LoadSchemeByTypeAsync(Type type)
LoadSchemeByTypeAsync<TProps>()
Load scheme by C# class type (throws exception if not found).
public Task<IRedbScheme> LoadSchemeByTypeAsync<TProps>() where TProps : class
LoadTreeAsync<TProps>(IRedbObject, int?)
Load tree/subtree (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<TreeRedbObject<TProps>> LoadTreeAsync<TProps>(IRedbObject rootObj, int? maxDepth = null) where TProps : class, new()
LoadTreeAsync<TProps>(IRedbObject, IRedbUser, int?)
Load tree/subtree with explicit user (uses config.DefaultCheckPermissionsOnLoad).
public Task<TreeRedbObject<TProps>> LoadTreeAsync<TProps>(IRedbObject rootObj, IRedbUser user, int? maxDepth = null) where TProps : class, new()
LoadTreeAsync<TProps>(long, int?)
Load tree/subtree by root object ID (uses _securityContext and config.DefaultCheckPermissionsOnLoad).
public Task<TreeRedbObject<TProps>> LoadTreeAsync<TProps>(long rootObjectId, int? maxDepth = null) where TProps : class, new()
LoadTreeAsync<TProps>(long, IRedbUser, int?)
Load tree/subtree by root object ID with explicit user (uses config.DefaultCheckPermissionsOnLoad).
public Task<TreeRedbObject<TProps>> LoadTreeAsync<TProps>(long rootObjectId, IRedbUser user, int? maxDepth = null) where TProps : class, new()
MigrateStructureTypeAsync(long, string, string, bool)
Migrate data when changing structure type (e.g. String -> Long).
public Task<TypeMigrationResult> MigrateStructureTypeAsync(long structureId, string oldTypeName, string newTypeName, bool dryRun = false)
MoveObjectAsync(IRedbObject, IRedbObject?, IRedbUser)
Move object in tree with explicit user (uses config.DefaultCheckPermissionsOnSave).
public Task MoveObjectAsync(IRedbObject obj, IRedbObject? newParentObj, IRedbUser user)
MoveObjectAsync(IRedbObject, IRedbObject?)
Move object in tree (uses _securityContext and config.DefaultCheckPermissionsOnSave).
public Task MoveObjectAsync(IRedbObject obj, IRedbObject? newParentObj)
PurgeTrashAsync(long, int, int, IProgress<PurgeProgress>?, CancellationToken)
Purge a trash container created by SoftDeleteAsync.
public Task PurgeTrashAsync(long trashId, int totalCount, int batchSize = 10, IProgress<PurgeProgress>? progress = null, CancellationToken cancellationToken = default)
Query<TProps>()
Create type-safe query by type (synchronous).
public IRedbQueryable<TProps> Query<TProps>() where TProps : class, new()
Query<TProps>(IRedbUser)
Create type-safe query by type with specified user (synchronous).
public IRedbQueryable<TProps> Query<TProps>(IRedbUser user) where TProps : class, new()
ReadEmbeddedSql()
Reads the embedded combined SQL initialization script (redb_init.sql).
protected abstract string ReadEmbeddedSql()
RevokeAllRolePermissionsAsync(IRedbRole, IRedbUser?)
Revoke all role permissions.
public Task<int> RevokeAllRolePermissionsAsync(IRedbRole role, IRedbUser? currentUser = null)
RevokeAllUserPermissionsAsync(IRedbUser, IRedbUser?)
Revoke all user permissions.
public Task<int> RevokeAllUserPermissionsAsync(IRedbUser user, IRedbUser? currentUser = null)
RevokePermissionAsync(IRedbRole, IRedbObject, IRedbUser?)
Revoke permission from role.
public Task<bool> RevokePermissionAsync(IRedbRole role, IRedbObject obj, IRedbUser? currentUser = null)
RevokePermissionAsync(IRedbUser, IRedbObject, IRedbUser?)
Revoke permission from user.
public Task<bool> RevokePermissionAsync(IRedbUser user, IRedbObject obj, IRedbUser? currentUser = null)
SaveAsync(IEnumerable<IRedbObject>, IRedbUser)
Bulk save of polymorphic objects with explicit user (uses config).
public Task<List<long>> SaveAsync(IEnumerable<IRedbObject> objects, IRedbUser user)
SaveAsync(IEnumerable<IRedbObject>)
Bulk save of polymorphic objects (uses _securityContext and config).
public Task<List<long>> SaveAsync(IEnumerable<IRedbObject> objects)
SaveAsync(IRedbObject, IRedbUser)
Save object to EAV with explicit user. Determines type internally.
public Task<long> SaveAsync(IRedbObject obj, IRedbUser user)
SaveAsync(IRedbObject)
Save object to EAV (uses _securityContext and config.DefaultCheckPermissionsOnSave).
public Task<long> SaveAsync(IRedbObject obj)
SaveAsync<TProps>(IRedbObject<TProps>, IRedbUser)
Save generic object to EAV with explicit user (uses config.DefaultCheckPermissionsOnSave).
public Task<long> SaveAsync<TProps>(IRedbObject<TProps> obj, IRedbUser user) where TProps : class, new()
SaveAsync<TProps>(IRedbObject<TProps>)
Save generic object to EAV (uses _securityContext and config.DefaultCheckPermissionsOnSave).
public Task<long> SaveAsync<TProps>(IRedbObject<TProps> obj) where TProps : class, new()
SchemeExistsByNameAsync(string)
Check if scheme exists by name.
public Task<bool> SchemeExistsByNameAsync(string schemeName)
SchemeExistsForTypeAsync(Type)
Check if scheme exists for C# class type.
public Task<bool> SchemeExistsForTypeAsync(Type type)
SchemeExistsForTypeAsync<TProps>()
Check if scheme exists for C# class type.
public Task<bool> SchemeExistsForTypeAsync<TProps>() where TProps : class
SoftDeleteAsync(IEnumerable<IRedbObject>, IRedbUser, long?)
Mark objects for soft-deletion with explicit user.
public Task<DeletionMark> SoftDeleteAsync(IEnumerable<IRedbObject> objects, IRedbUser user, long? trashParentId = null)
SoftDeleteAsync(IEnumerable<IRedbObject>, long?)
Mark objects for soft-deletion (uses _securityContext).
public Task<DeletionMark> SoftDeleteAsync(IEnumerable<IRedbObject> objects, long? trashParentId = null)
SoftDeleteAsync(IEnumerable<long>, IRedbUser, long?)
Mark objects for soft-deletion with explicit user.
public Task<DeletionMark> SoftDeleteAsync(IEnumerable<long> objectIds, IRedbUser user, long? trashParentId = null)
SoftDeleteAsync(IEnumerable<long>, long?)
Mark objects for soft-deletion (uses _securityContext).
public Task<DeletionMark> SoftDeleteAsync(IEnumerable<long> objectIds, long? trashParentId = null)
SyncSchemeAsync<TProps>()
Simplified scheme synchronization method with auto-detection of name and alias.
public Task<IRedbScheme> SyncSchemeAsync<TProps>() where TProps : class
SyncStructuresFromTypeAsync<TProps>(IRedbScheme, bool)
Synchronize scheme structures from Props type (by default deletes extra fields).
public Task<List<IRedbStructure>> SyncStructuresFromTypeAsync<TProps>(IRedbScheme scheme, bool strictDeleteExtra = true) where TProps : class
TableExistsAsync(string)
Checks whether the specified table exists in the database.
protected abstract Task<bool> TableExistsAsync(string tableName)
TreeQuery<TProps>()
Create type-safe tree query by type (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>() where TProps : class, new()
TreeQuery<TProps>(IEnumerable<IRedbObject>, int?)
Create tree query limited to subtrees of object list (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>(IEnumerable<IRedbObject> rootObjects, int? maxDepth = null) where TProps : class, new()
TreeQuery<TProps>(IEnumerable<IRedbObject>, IRedbUser, int?)
Create tree query limited to subtrees of object list with specified user (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>(IEnumerable<IRedbObject> rootObjects, IRedbUser user, int? maxDepth = null) where TProps : class, new()
TreeQuery<TProps>(IEnumerable<long>, int?)
Create tree query limited to subtrees by ID list (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>(IEnumerable<long> rootObjectIds, int? maxDepth = null) where TProps : class, new()
TreeQuery<TProps>(IEnumerable<long>, IRedbUser, int?)
Create tree query limited to subtrees by ID list with specified user (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>(IEnumerable<long> rootObjectIds, IRedbUser user, int? maxDepth = null) where TProps : class, new()
TreeQuery<TProps>(IRedbObject?, int?)
Create tree query limited to subtree (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>(IRedbObject? rootObject, int? maxDepth = null) where TProps : class, new()
TreeQuery<TProps>(IRedbObject?, IRedbUser, int?)
Create tree query limited to subtree with specified user (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>(IRedbObject? rootObject, IRedbUser user, int? maxDepth = null) where TProps : class, new()
TreeQuery<TProps>(IRedbUser)
Create type-safe tree query by type with specified user (synchronous).
public IRedbQueryable<TProps> TreeQuery<TProps>(IRedbUser user) where TProps : class, new()
TreeQuery<TProps>(long, int?)
Create tree query limited to subtree (synchronous, by ID).
public IRedbQueryable<TProps> TreeQuery<TProps>(long rootObjectId, int? maxDepth = null) where TProps : class, new()
TreeQuery<TProps>(long, IRedbUser, int?)
Create tree query limited to subtree with specified user (synchronous, by ID).
public IRedbQueryable<TProps> TreeQuery<TProps>(long rootObjectId, IRedbUser user, int? maxDepth = null) where TProps : class, new()
TryClaimOrphanedTaskAsync(long, int)
Atomically claim an orphaned task for processing.
public Task<bool> TryClaimOrphanedTaskAsync(long trashId, int timeoutMinutes = 30)
UpdateConfiguration(Action<RedbServiceConfiguration>)
Update configuration.
public void UpdateConfiguration(Action<RedbServiceConfiguration> configure)
UpdateConfiguration(Action<RedbServiceConfigurationBuilder>)
Update configuration via builder.
public void UpdateConfiguration(Action<RedbServiceConfigurationBuilder> configureBuilder)
UpdatePermissionAsync(IRedbPermission, PermissionRequest, IRedbUser?)
Update permission.
public Task<IRedbPermission> UpdatePermissionAsync(IRedbPermission permission, PermissionRequest request, IRedbUser? currentUser = null)
ValidatePropertyConstraints(Type, string, bool, bool)
Validate property constraints and arrays.
public ValidationIssue? ValidatePropertyConstraints(Type propertyType, string propertyName, bool isRequired, bool isArray)
ValidateSchemaAsync<TProps>(IRedbScheme, bool)
Validate schema before synchronization (with contract).
public Task<SchemaValidationResult> ValidateSchemaAsync<TProps>(IRedbScheme scheme, bool strictDeleteExtra = true) where TProps : class
ValidateSchemaAsync<TProps>(string, bool)
Validate schema before synchronization.
public Task<SchemaValidationResult> ValidateSchemaAsync<TProps>(string schemeName, bool strictDeleteExtra = true) where TProps : class
ValidateTypeAsync(Type, string)
Validate C# type correspondence with REDB supported types.
public Task<ValidationIssue?> ValidateTypeAsync(Type csharpType, string propertyName)
WarmupMetadataCacheAsync()
Warmup metadata cache. Override in derived classes for DB-specific SQL.
protected virtual Task WarmupMetadataCacheAsync()
Constructors
RedbServiceBase(IServiceProvider)
Initialize RedbServiceBase with dependency injection.