简体   繁体   中英

Can I use LINQ to get more than 100 records back from a Quickbooks Online ServiceContext?

For my Quickbooks Online integration, I'm using the .NET SDK and was previously using LINQ to access data from a ServiceContext :

var paymentMethodsService = new QueryService<PaymentMethod>(ServiceContext);
_paymentMethods = paymentMethodsService.Select(x => x).ToList();

When testing, we noticed that this only returns the first 100 records. (Presumably because this is the default page size?)

We can get around this by using a query containing MAXRESULTS :

var itemsService = new QueryService<Item>(ServiceContext);
_items = itemsService.ExecuteIdsQuery("SELECT * FROM Item MAXRESULTS 1000").ToList();

My question is, can I achieve the same result without using a query string?

I must admit I have no idea what Quickbooks Online even is, but nevertheless I think you can override default page size with LINQ Take(yourPageSize) . Though it's still not clear how to fetch ALL items in a collection this way, without knowing total count beforehand. Hopefully you don't need to do this in your scenario (or if you do - maybe you can just use arbitrary large number for Take if you won't find another way).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM