如何使用带有ASP.NET核心标识的Dapper? [英] How to use dapper with ASP.Net core Identity?

查看:22
本文介绍了如何使用带有ASP.NET核心标识的Dapper?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,我正在尝试使用具有核心身份的Dapper对数据库进行查询。但是我被困在这一点上了。我使用的是来自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();
    }

谢谢!

推荐答案

请看一下我最近上传到gihub上的一个项目--https://github.com/giorgos07/Daarto这正是您需要的。

这篇关于如何使用带有ASP.NET核心标识的Dapper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆