Class RoleStore<TKey, TRole, TRoleClaim>
Creates a new instance of a persistence store for roles.
public class RoleStore<TKey, TRole, TRoleClaim> : IQueryableRoleStore<TRole>, IRoleClaimStore<TRole>, IRoleStore<TRole>, IDisposable where TKey : IEquatable<TKey> where TRole : class, IIdentityRole<TKey> where TRoleClaim : class, IIdentityRoleClaim<TKey>, new()
Type Parameters
TKeyThe type of the primary key for a role.
TRoleThe type of the class representing a role.
TRoleClaimThe type of the class representing a role claim.
- Inheritance
-
RoleStore<TKey, TRole, TRoleClaim>
- Implements
-
IQueryableRoleStore<TRole>IRoleClaimStore<TRole>IRoleStore<TRole>
- Derived
Constructors
RoleStore(IConnectionFactory, IdentityErrorDescriber)
Constructs a new instance of RoleStore<TKey, TRole, TRoleClaim>.
public RoleStore(IConnectionFactory factory, IdentityErrorDescriber describer = null)
Parameters
factoryIConnectionFactorydescriberIdentityErrorDescriber
Properties
ErrorDescriber
Gets or sets the IdentityErrorDescriber for any error that occurred with the current operation.
public IdentityErrorDescriber ErrorDescriber { get; set; }
Property Value
Roles
A navigation property for the roles the store contains.
public virtual IQueryable<TRole> Roles { get; }
Property Value
- IQueryable<TRole>
Methods
AddClaimAsync(DataConnection, TRole, Claim, CancellationToken)
Adds the claim given to the specified role.
protected virtual Task AddClaimAsync(DataConnection db, TRole role, Claim claim, CancellationToken cancellationToken)
Parameters
dbDataConnectionroleTRoleThe role to add the claim to.
claimClaimThe claim to add to the role.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
AddClaimAsync(TRole, Claim, CancellationToken)
Adds the claim given to the specified role.
public Task AddClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role to add the claim to.
claimClaimThe claim to add to the role.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
ConvertIdFromString(string)
Converts the provided id to a strongly typed key object.
public virtual TKey ConvertIdFromString(string id)
Parameters
idstringThe id to convert.
Returns
- TKey
An instance of
TKeyrepresenting the providedid.
ConvertIdToString(TKey)
Converts the provided id to its string representation.
public virtual string ConvertIdToString(TKey id)
Parameters
idTKeyThe id to convert.
Returns
CreateAsync(DataConnection, TRole, CancellationToken)
Creates a new role in a store as an asynchronous operation.
protected virtual Task<IdentityResult> CreateAsync(DataConnection db, TRole role, CancellationToken cancellationToken)
Parameters
dbDataConnectionroleTRoleThe role to create in the store.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A Task<TResult> that represents the IdentityResult of the asynchronous query.
CreateAsync(TRole, CancellationToken)
Creates a new role in a store as an asynchronous operation.
public Task<IdentityResult> CreateAsync(TRole role, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role to create in the store.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A Task<TResult> that represents the IdentityResult of the asynchronous query.
CreateRoleClaim(TRole, Claim)
Creates a entity representing a role claim.
protected virtual TRoleClaim CreateRoleClaim(TRole role, Claim claim)
Parameters
roleTRoleThe associated role.
claimClaimThe associated claim.
Returns
- TRoleClaim
The role claim entity.
DeleteAsync(TRole, CancellationToken)
Deletes a role from the store as an asynchronous operation.
public Task<IdentityResult> DeleteAsync(TRole role, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role to delete from the store.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A Task<TResult> that represents the IdentityResult of the asynchronous query.
Dispose()
Dispose the stores
public void Dispose()
FindByIdAsync(DataConnection, TKey, CancellationToken)
Finds the role who has the specified ID as an asynchronous operation.
protected virtual Task<TRole> FindByIdAsync(DataConnection db, TKey roleId, CancellationToken cancellationToken)
Parameters
dbDataConnectionroleIdTKeycancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TRole>
A Task<TResult> that result of the look up.
FindByIdAsync(string, CancellationToken)
Finds the role who has the specified ID as an asynchronous operation.
public Task<TRole> FindByIdAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringThe role ID to look for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TRole>
A Task<TResult> that result of the look up.
FindByNameAsync(DataConnection, string, CancellationToken)
Finds the role who has the specified normalized name as an asynchronous operation.
protected virtual Task<TRole> FindByNameAsync(DataConnection db, string normalizedName, CancellationToken cancellationToken)
Parameters
dbDataConnectionnormalizedNamestringThe normalized role name to look for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TRole>
A Task<TResult> that result of the look up.
FindByNameAsync(string, CancellationToken)
Finds the role who has the specified normalized name as an asynchronous operation.
public Task<TRole> FindByNameAsync(string normalizedName, CancellationToken cancellationToken = default)
Parameters
normalizedNamestringThe normalized role name to look for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TRole>
A Task<TResult> that result of the look up.
GetClaimsAsync(DataConnection, TRole, CancellationToken)
Get the claims associated with the specified role as an asynchronous operation.
protected virtual Task<IList<Claim>> GetClaimsAsync(DataConnection db, TRole role, CancellationToken cancellationToken)
Parameters
dbDataConnectionroleTRoleThe role whose claims should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<Claim>>
A Task<TResult> that contains the claims granted to a role.
GetClaimsAsync(TRole, CancellationToken)
Get the claims associated with the specified role as an asynchronous operation.
public Task<IList<Claim>> GetClaimsAsync(TRole role, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role whose claims should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<Claim>>
A Task<TResult> that contains the claims granted to a role.
GetConnection()
Gets DataConnection from supplied IConnectionFactory
protected DataConnection GetConnection()
Returns
GetContext()
Gets IDataContext from supplied IConnectionFactory
protected IDataContext GetContext()
Returns
GetNormalizedRoleNameAsync(TRole, CancellationToken)
Get a role's normalized name as an asynchronous operation.
public virtual Task<string> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role whose normalized name should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
A Task<TResult> that contains the name of the role.
GetRoleIdAsync(TRole, CancellationToken)
Gets the ID for a role from the store as an asynchronous operation.
public Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role whose ID should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
A Task<TResult> that contains the ID of the role.
GetRoleNameAsync(TRole, CancellationToken)
Gets the name of a role from the store as an asynchronous operation.
public Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role whose name should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
A Task<TResult> that contains the name of the role.
RemoveClaimAsync(DataConnection, TRole, Claim, CancellationToken)
Removes the claim given from the specified role.
protected virtual Task RemoveClaimAsync(DataConnection db, TRole role, Claim claim, CancellationToken cancellationToken)
Parameters
dbDataConnectionroleTRoleThe role to remove the claim from.
claimClaimThe claim to remove from the role.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
RemoveClaimAsync(TRole, Claim, CancellationToken)
Removes the claim given from the specified role.
public Task RemoveClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role to remove the claim from.
claimClaimThe claim to remove from the role.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetNormalizedRoleNameAsync(TRole, string, CancellationToken)
Set a role's normalized name as an asynchronous operation.
public virtual Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role whose normalized name should be set.
normalizedNamestringThe normalized name to set
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetRoleNameAsync(TRole, string, CancellationToken)
Sets the name of a role in the store as an asynchronous operation.
public Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role whose name should be set.
roleNamestringThe name of the role.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
ThrowIfDisposed()
Throws if this class has been disposed.
protected void ThrowIfDisposed()
UpdateAsync(DataConnection, TRole, CancellationToken)
Updates a role in a store as an asynchronous operation.
protected virtual Task<IdentityResult> UpdateAsync(DataConnection db, TRole role, CancellationToken cancellationToken)
Parameters
dbDataConnectionroleTRoleThe role to update in the store.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A Task<TResult> that represents the IdentityResult of the asynchronous query.
UpdateAsync(TRole, CancellationToken)
Updates a role in a store as an asynchronous operation.
public Task<IdentityResult> UpdateAsync(TRole role, CancellationToken cancellationToken = default)
Parameters
roleTRoleThe role to update in the store.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
A Task<TResult> that represents the IdentityResult of the asynchronous query.