I am trying to test my code by getting 10 specific users that was created recently or having a specific character. I have based my code to this one. This code is from Dan. Changing passwordFormat from Encrypted to Hashed
void HashAllPasswords()
    {
        var clearProvider = Membership.Providers["SqlProvider_Clear"];
        var hashedProvider = Membership.Providers["SqlProvider_Hashed"];
        int dontCare = 2;
        if (clearProvider == null || hashedProvider == null) return;
                        var passwords = encrypted.GetAllUsers(0, int.MaxValue, out dontCare)
        .Cast<MembershipUser>().Where(u => u.IsLockedOut == false && u.IsApproved == true).OrderByDescending(u => u.CreationDate).ToDictionary(u => u.UserName, u => u.GetPassword());
    
        using (var conn = new SqlConnection(
               ConfigurationManager.ConnectionStrings[0].ConnectionString))
        {
            conn.Open();
            using (var cmd = new SqlCommand(
                   "UPDATE [aspnet_Membership] SET [PasswordFormat]=1", conn))
                cmd.ExecuteNonQuery();
        }
    var count = 0;
        foreach (var entry in passwords)
        {
            var resetPassword = hashedProvider.ResetPassword(entry.Key, null);
            hashedProvider.ChangePassword(entry.Key, resetPassword, entry.Value);
            count++;
        if (count == 2)
            break;
        }
    }
So basically instead of changing all the users I just wanted to change 10 users or maybe 100 depending on the amount that I wanted. Also I am receiving an error in
var records
it says
The error is
Item has already been added. Key in dictionary: 'sample@email.com' Key being added: 'sample@email.com'.
Is there a way to resolve this? Maybe I am using linq in the wrong way.