Asp.net-Core
如何將 dapper 與 ASP.Net 核心身份一起使用?
我有一個數據庫,我正在嘗試使用 dapper 和 Core Identity 來查詢數據庫。但我被困在這一點上。我正在使用來自 identityUser 界面的使用者:
public class User : IdentityUser { }使用 dapper 為 CRUD 製作自定義使用者儲存。
public class UserStore : IUserStore<User> { private readonly string connectionString; public UserStore(IConfiguration configuration) { connectionString = configuration.GetValue<string>("DBInfo:ConnectionString"); } internal IDbConnection Connection { get { return new SqlConnection(connectionString); } } public Task<IdentityResult> CreateAsync(User user, CancellationToken cancellationToken) { **// HOW TO I RETURN A USER WITH DAPPER HERE?** } public Task<IdentityResult> DeleteAsync(User user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public void Dispose() { throw new NotImplementedException(); } public Task<User> FindByIdAsync(string userId, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task<User> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task<string> GetUserIdAsync(User user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task<string> GetUserNameAsync(User user, CancellationToken cancellationToken) { throw new NotImplementedException(); } public Task<IdentityResult> UpdateAsync(User user, CancellationToken cancellationToken) { throw new NotImplementedException(); }謝謝!
請看一下我最近在 GitHub 上上傳的一個項目 - <https://github.com/giorgos07/Daarto>這正是您所需要的。