private IEnumerable <IMembershipAccount> Find(Action <IDbCommand> prepareCommand, int pageIndex, int pageSize,
                                                      out int totalRecords)
        {
            using (var connection = CreateAndOpenConnection())
            {
                var sql = "SELECT count(*) FROM membership_accounts";
                using (var cmd = connection.CreateCommand(sql))
                {
                    prepareCommand(cmd);
                    totalRecords = (int)cmd.ExecuteScalar();
                }

                sql = "SELECT * FROM membership_accounts";
                sql = _sqlAdapter.PageSql(sql, pageIndex, pageSize);
                using (var cmd = connection.CreateCommand(sql))
                {
                    prepareCommand(cmd);
                    using (var reader = cmd.ExecuteReader())
                    {
                        var accounts = new List <IMembershipAccount>();
                        while (reader.Read())
                        {
                            var account = CreateAccount();
                            MapAccount(reader, account);
                            accounts.Add(account);
                        }
                        return(accounts);
                    }
                }
            }
        }