我需要将ASP.NET Identity UserId作为参数传递给存储过程,但我不确定如何从登录用户获取ID?
存储过程:
CREATE PROCEDURE [dbo].[GetUserProfile]
@UserId nvarchar(128)
AS
BEGIN
SELECT Avatar, City, [State]
FROM UserProfiles
WHERE UserId = @UserId
END
来自存储库的存储过程调用:
public List<UserModels.UserProfile> GetUserProfile()
{
using (var connection = new SqlConnection(SQLSettings.GetConnectionString()))
{
return connection.Query<UserModels.UserProfile>("GetUserProfile", commandType: CommandType.StoredProcedure).ToList();
}
}