如何使用ASP.Net核心身份的短小精灵?
问题描述:
我有一个数据库和iam试图使用核心身份的矮胖来查询数据库。但我坚持在这一点上。我使用的是用户从identityUser的接口:如何使用ASP.Net核心身份的短小精灵?
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();
}
谢谢!
我建议你阅读文档:https://github.com/StackExchange/Dapper它基本上是'SqlConnection' /'IDbConnection'上的扩展库。 –
你究竟在问什么?如何根据我们尚未见过的数据库结构编写创建逻辑?这个问题太不清楚,而且答案太广泛。 –
'公共任务 CreateAsync(用户用户,CancellationToken cancellationToken) { ** //如何在此返回用户?** }' –
Javier