Table of Contents

Class RoleStore<TKey, TRole, TRoleClaim>

Namespace
LinqToDB.Identity
Assembly
LinqToDB.Identity.dll

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
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 IConnectionFactory

IConnectionFactory

describer IdentityErrorDescriber

The IdentityErrorDescriber.

Properties

ErrorDescriber

Gets or sets the IdentityErrorDescriber for any error that occurred with the current operation.

public IdentityErrorDescriber ErrorDescriber { get; set; }

Property Value

IdentityErrorDescriber

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 DataConnection
role TRole

The role to add the claim to.

claim Claim

The claim to add to the role.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

AddClaimAsync(TRole, Claim, CancellationToken)

Adds the claim given to the specified role.

public Task AddClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default)

Parameters

role TRole

The role to add the claim to.

claim Claim

The claim to add to the role.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

ConvertIdFromString(string)

Converts the provided id to a strongly typed key object.

public virtual TKey ConvertIdFromString(string id)

Parameters

id string

The id to convert.

Returns

TKey

An instance of TKey representing the provided id.

ConvertIdToString(TKey)

Converts the provided id to its string representation.

public virtual string ConvertIdToString(TKey id)

Parameters

id TKey

The id to convert.

Returns

string

An string representation of the provided id.

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 DataConnection
role TRole

The role to create in the store.

cancellationToken CancellationToken

The 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 TRole

The role to create in the store.

cancellationToken CancellationToken

The 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 TRole

The associated role.

claim Claim

The 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 TRole

The role to delete from the store.

cancellationToken CancellationToken

The 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 DataConnection
roleId TKey
cancellationToken CancellationToken

The 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 string

The role ID to look for.

cancellationToken CancellationToken

The 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 DataConnection
normalizedName string

The normalized role name to look for.

cancellationToken CancellationToken

The 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 string

The normalized role name to look for.

cancellationToken CancellationToken

The 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 DataConnection
role TRole

The role whose claims should be retrieved.

cancellationToken CancellationToken

The 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 TRole

The role whose claims should be retrieved.

cancellationToken CancellationToken

The 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()

protected DataConnection GetConnection()

Returns

DataConnection

DataConnection

GetContext()

Gets IDataContext from supplied IConnectionFactory

protected IDataContext GetContext()

Returns

IDataContext

IDataContext

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 TRole

The role whose normalized name should be retrieved.

cancellationToken CancellationToken

The 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 TRole

The role whose ID should be returned.

cancellationToken CancellationToken

The 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 TRole

The role whose name should be returned.

cancellationToken CancellationToken

The 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 DataConnection
role TRole

The role to remove the claim from.

claim Claim

The claim to remove from the role.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveClaimAsync(TRole, Claim, CancellationToken)

Removes the claim given from the specified role.

public Task RemoveClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default)

Parameters

role TRole

The role to remove the claim from.

claim Claim

The claim to remove from the role.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

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 TRole

The role whose normalized name should be set.

normalizedName string

The normalized name to set

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

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 TRole

The role whose name should be set.

roleName string

The name of the role.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

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 DataConnection
role TRole

The role to update in the store.

cancellationToken CancellationToken

The 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 TRole

The role to update in the store.

cancellationToken CancellationToken

The 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.