public GroupTestViewModel(IAccountBalanceDataService service)
        {
            var accountsTable = service.Accounts;

            _groupedAccounts = new AggregatedTable(accountsTable);
            _groupedAccounts.GroupBy <int>(AccountColumns.PersonId);
            var balanceColumn = (IReactiveColumn <decimal>)accountsTable.GetColumnByName(AccountColumns.AccountBalance);

            _groupedAccounts.AddAggregate(balanceColumn, SumColumnId, () => new Sum <decimal>());
            _groupedAccounts.AddAggregate(balanceColumn, CountColumnId, () => new Count <decimal>());
            _groupedAccounts.FinishInitialisation();

            var groups = new IndexedObservableCollection <BalanceGroup, int>(g => g.RowIndex);

            _groupedAccounts.ReplayAndSubscribe(
                update =>
            {
                if (update.Action == TableUpdateAction.Add)
                {
                    groups.Add(new BalanceGroup(_groupedAccounts, update.RowIndex));
                }
                else if (update.Action == TableUpdateAction.Delete)
                {
                    groups.RemoveAt(groups.GetIndexForKey(update.RowIndex));
                }
            });

            var accounts = new IndexedObservableCollection <AccountViewModel, int>(a => a.RowIndex);

            accountsTable.ReplayAndSubscribe(
                update =>
            {
                if (update.Action == TableUpdateAction.Add)
                {
                    var accountViewModel = new AccountViewModel(accountsTable, update.RowIndex);
                    accounts.Add(accountViewModel);
                    Debug.WriteLine("{1},Adding,,{0},", update.RowIndex, DateTime.Now.ToLongTimeString());
                }
                else if (update.Action == TableUpdateAction.Delete)
                {
                    var indexForKey      = accounts.GetIndexForKey(update.RowIndex);
                    var accountViewModel = accounts[indexForKey];
                    accounts.RemoveAt(indexForKey);
                    Debug.WriteLine("{1},Removing,{0}", accountViewModel.PersonId, DateTime.Now.ToLongTimeString());
                }
                else
                {
                    var indexForKey      = accounts.GetIndexForKey(update.RowIndex);
                    var accountViewModel = accounts[indexForKey];
                    Debug.WriteLine("{1},Modifying,{0},{2},{3}",
                                    accountViewModel.PersonId, DateTime.Now.ToLongTimeString(), update.RowIndex, update.Column.ColumnId);
                }
            });
            Groups   = groups;
            Accounts = accounts;
        }