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
TKey
The type of the primary key for a role.
TRole
The type of the class representing a role.
TRoleClaim
The 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
factory
IConnectionFactorydescriber
IdentityErrorDescriber
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
db
DataConnectionrole
TRoleThe role to add the claim to.
claim
ClaimThe claim to add to the role.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role to add the claim to.
claim
ClaimThe claim to add to the role.
cancellationToken
CancellationTokenThe 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
id
stringThe id to convert.
Returns
- TKey
An instance of
TKey
representing the providedid
.
ConvertIdToString(TKey)
Converts the provided id
to its string representation.
public virtual string ConvertIdToString(TKey id)
Parameters
id
TKeyThe 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
db
DataConnectionrole
TRoleThe role to create in the store.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role to create in the store.
cancellationToken
CancellationTokenThe 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
role
TRoleThe associated role.
claim
ClaimThe 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
role
TRoleThe role to delete from the store.
cancellationToken
CancellationTokenThe 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
db
DataConnectionroleId
TKeycancellationToken
CancellationTokenThe 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
id
stringThe role ID to look for.
cancellationToken
CancellationTokenThe 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
db
DataConnectionnormalizedName
stringThe normalized role name to look for.
cancellationToken
CancellationTokenThe 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
normalizedName
stringThe normalized role name to look for.
cancellationToken
CancellationTokenThe 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
db
DataConnectionrole
TRoleThe role whose claims should be retrieved.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role whose claims should be retrieved.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role whose normalized name should be retrieved.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role whose ID should be returned.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role whose name should be returned.
cancellationToken
CancellationTokenThe 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
db
DataConnectionrole
TRoleThe role to remove the claim from.
claim
ClaimThe claim to remove from the role.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role to remove the claim from.
claim
ClaimThe claim to remove from the role.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role whose normalized name should be set.
normalizedName
stringThe normalized name to set
cancellationToken
CancellationTokenThe 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
role
TRoleThe role whose name should be set.
roleName
stringThe name of the role.
cancellationToken
CancellationTokenThe 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
db
DataConnectionrole
TRoleThe role to update in the store.
cancellationToken
CancellationTokenThe 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
role
TRoleThe role to update in the store.
cancellationToken
CancellationTokenThe 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.