I'm trying to convert a method to use a stored procedure with Dapper. But I'm quite confused with what's going on with var result =...
public Task<TUser> FindByIdAsync(Guid userId)
{
var sql = @"SELECT *
FROM IdentityUser
WHERE UserId = @USERID";
using (var connection = new SqlConnection(_connection))
{
var result = connection.Query<TUser, IdentityProfile, TUser>(sql, (user, profile) => { user.Profile = profile;
return user; },
new { userId }, splitOn: "UserId").SingleOrDefault();
return Task.FromResult(result);
}
}
Here is what I have:
public Task<TUser> FindByIdAsync(Guid userId)
{
using (var connection = new SqlConnection(_connection))
{
var param = new DynamicParameters();
param.Add("@UserId", userId);
return Task.FromResult(connection.Query("IdentityGetUserById", param, commandType: CommandType.StoredProcedure).SingleOrDefault());
}
}