如何使用ASP.Net核心标识的dapper?

Gon*_*alo 13 dapper asp.net-identity asp.net-core

我有一个数据库,我试图使用dapper与核心身份来查询数据库.但我在这一点上陷入困​​境.我从identityUser的界面使用用户:

public class User : IdentityUser
{

}
Run Code Online (Sandbox Code Playgroud)

使用精巧的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();
    }
Run Code Online (Sandbox Code Playgroud)

谢谢!

Gio*_*zas 11

请看一下我最近在GitHub上传的项目 - https://github.com/giorgos07/Daarto这正是你需要的.


小智 5

你看过Identity.Dapper了吗?