
Xero.NetStandard.OAuth2 For Each
Hi,
I am upgrading to use the OAuth2 from C# Xero Client.
My original code uses api.Accounts.Find().ToList() to get a list of accounts, I then do a foreach loop on the list of accounts.
With the new api I am using, Accounts Ledgers = await api.GetAccountsAsync(_accessToken, _xeroTenantId.ToString()); to get a list of accounts.
My problem is that I cannot do a foreach on the returned Accounts the error is "foreach statement cannot operate on variables of type 'Accounts' because 'Accounts' does not contain a public instance or extension definition for 'GetEnumerator'"
Any help/advise would be much appreciated.
Thanks
John
I am upgrading to use the OAuth2 from C# Xero Client.
My original code uses api.Accounts.Find().ToList() to get a list of accounts, I then do a foreach loop on the list of accounts.
With the new api I am using, Accounts Ledgers = await api.GetAccountsAsync(_accessToken, _xeroTenantId.ToString()); to get a list of accounts.
My problem is that I cannot do a foreach on the returned Accounts the error is "foreach statement cannot operate on variables of type 'Accounts' because 'Accounts' does not contain a public instance or extension definition for 'GetEnumerator'"
Any help/advise would be much appreciated.
Thanks
John
1
Replies

Solved it myself.
If anyone else finds this it was quite simple originally I had:-
foreach (var account in Ledgers)
Changed it to:-
foreach (var account in Ledgers._Accounts)
note the _Accounts
If anyone else finds this it was quite simple originally I had:-
foreach (var account in Ledgers)
Changed it to:-
foreach (var account in Ledgers._Accounts)
note the _Accounts