Table of Contents

Class SqliteIdentityStorage

Namespace
Hi.SqliteUtils
Assembly
HiNc.dll

SQLite-based storage for ASP.NET Core Identity. Replaces MongoDB-based identity storage.

public class SqliteIdentityStorage : IDisposable
Inheritance
SqliteIdentityStorage
Implements
Inherited Members
Extension Methods

Constructors

SqliteIdentityStorage(string)

Initializes a new instance of the SqliteIdentityStorage class.

public SqliteIdentityStorage(string databasePath = null)

Parameters

databasePath string

The path to the SQLite database file.

Properties

DatabasePath

Gets the database file path.

public string DatabasePath { get; }

Property Value

string

Default

Gets or sets the default SQLite identity storage instance.

public static SqliteIdentityStorage Default { get; set; }

Property Value

SqliteIdentityStorage

IsDefaultInit

Gets a value indicating whether the default storage has been initialized.

public static bool IsDefaultInit { get; }

Property Value

bool

Methods

AddToRoleAsync(string, string, CancellationToken)

public Task AddToRoleAsync(string userId, string normalizedRoleName, CancellationToken cancellationToken)

Parameters

userId string
normalizedRoleName string
cancellationToken CancellationToken

Returns

Task

ClearAllData()

Clears all identity data (users, roles, and user-role associations).

public void ClearAllData()

CreateRoleAsync<TRole>(TRole, CancellationToken)

public Task<IdentityResult> CreateRoleAsync<TRole>(TRole role, CancellationToken cancellationToken) where TRole : SqliteIdentityRole

Parameters

role TRole
cancellationToken CancellationToken

Returns

Task<IdentityResult>

Type Parameters

TRole

CreateUserAsync<TUser>(TUser, CancellationToken)

public Task<IdentityResult> CreateUserAsync<TUser>(TUser user, CancellationToken cancellationToken) where TUser : SqliteIdentityUser

Parameters

user TUser
cancellationToken CancellationToken

Returns

Task<IdentityResult>

Type Parameters

TUser

DeleteRoleAsync<TRole>(TRole, CancellationToken)

public Task<IdentityResult> DeleteRoleAsync<TRole>(TRole role, CancellationToken cancellationToken) where TRole : SqliteIdentityRole

Parameters

role TRole
cancellationToken CancellationToken

Returns

Task<IdentityResult>

Type Parameters

TRole

DeleteUserAsync<TUser>(TUser, CancellationToken)

public Task<IdentityResult> DeleteUserAsync<TUser>(TUser user, CancellationToken cancellationToken) where TUser : SqliteIdentityUser

Parameters

user TUser
cancellationToken CancellationToken

Returns

Task<IdentityResult>

Type Parameters

TUser

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

FindRoleByIdAsync<TRole>(string, CancellationToken)

public Task<TRole> FindRoleByIdAsync<TRole>(string roleId, CancellationToken cancellationToken) where TRole : SqliteIdentityRole, new()

Parameters

roleId string
cancellationToken CancellationToken

Returns

Task<TRole>

Type Parameters

TRole

FindRoleByNameAsync<TRole>(string, CancellationToken)

public Task<TRole> FindRoleByNameAsync<TRole>(string normalizedName, CancellationToken cancellationToken) where TRole : SqliteIdentityRole, new()

Parameters

normalizedName string
cancellationToken CancellationToken

Returns

Task<TRole>

Type Parameters

TRole

FindUserByEmailAsync<TUser>(string, CancellationToken)

public Task<TUser> FindUserByEmailAsync<TUser>(string normalizedEmail, CancellationToken cancellationToken) where TUser : SqliteIdentityUser, new()

Parameters

normalizedEmail string
cancellationToken CancellationToken

Returns

Task<TUser>

Type Parameters

TUser

FindUserByIdAsync<TUser>(string, CancellationToken)

public Task<TUser> FindUserByIdAsync<TUser>(string userId, CancellationToken cancellationToken) where TUser : SqliteIdentityUser, new()

Parameters

userId string
cancellationToken CancellationToken

Returns

Task<TUser>

Type Parameters

TUser

FindUserByNameAsync<TUser>(string, CancellationToken)

public Task<TUser> FindUserByNameAsync<TUser>(string normalizedUserName, CancellationToken cancellationToken) where TUser : SqliteIdentityUser, new()

Parameters

normalizedUserName string
cancellationToken CancellationToken

Returns

Task<TUser>

Type Parameters

TUser

GetRolesAsync(string, CancellationToken)

public Task<IList<string>> GetRolesAsync(string userId, CancellationToken cancellationToken)

Parameters

userId string
cancellationToken CancellationToken

Returns

Task<IList<string>>

GetRoles<TRole>()

public IQueryable<TRole> GetRoles<TRole>() where TRole : SqliteIdentityRole, new()

Returns

IQueryable<TRole>

Type Parameters

TRole

GetUsersInRoleAsync<TUser>(string, CancellationToken)

public Task<IList<TUser>> GetUsersInRoleAsync<TUser>(string normalizedRoleName, CancellationToken cancellationToken) where TUser : SqliteIdentityUser, new()

Parameters

normalizedRoleName string
cancellationToken CancellationToken

Returns

Task<IList<TUser>>

Type Parameters

TUser

GetUsers<TUser>()

public IQueryable<TUser> GetUsers<TUser>() where TUser : SqliteIdentityUser, new()

Returns

IQueryable<TUser>

Type Parameters

TUser

IsInRoleAsync(string, string, CancellationToken)

public Task<bool> IsInRoleAsync(string userId, string normalizedRoleName, CancellationToken cancellationToken)

Parameters

userId string
normalizedRoleName string
cancellationToken CancellationToken

Returns

Task<bool>

RemoveFromRoleAsync(string, string, CancellationToken)

public Task RemoveFromRoleAsync(string userId, string normalizedRoleName, CancellationToken cancellationToken)

Parameters

userId string
normalizedRoleName string
cancellationToken CancellationToken

Returns

Task

UpdateRoleAsync<TRole>(TRole, CancellationToken)

public Task<IdentityResult> UpdateRoleAsync<TRole>(TRole role, CancellationToken cancellationToken) where TRole : SqliteIdentityRole

Parameters

role TRole
cancellationToken CancellationToken

Returns

Task<IdentityResult>

Type Parameters

TRole

UpdateUserAsync<TUser>(TUser, CancellationToken)

public Task<IdentityResult> UpdateUserAsync<TUser>(TUser user, CancellationToken cancellationToken) where TUser : SqliteIdentityUser

Parameters

user TUser
cancellationToken CancellationToken

Returns

Task<IdentityResult>

Type Parameters

TUser