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

时间:2017-03-31 12:30:42

标签: asp.net-core asp.net-identity dapper

我有一个数据库,并且iam尝试使用带有Core Identity的dapper来对数据库进行查询。但我在这一点上陷入困​​境。我在identityUser的界面中使用用户:

public class User : IdentityUser
{

}

使用精巧的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();
    }

谢谢!

2 个答案:

答案 0 :(得分:9)

请查看我最近在GitHub上传的项目 - https://github.com/giorgos07/Daarto这正是您所需要的。

答案 1 :(得分:5)

你看过Identity.Dapper

吗?