The query filters of the QuickBooks Online .NET SDK enable your app to retrieve entities whose properties meet specified criteria. For example, your app can retrieve only those customer entities that have been created within the last 20 days.
Note
Note
To get the SDK to log the queries, enable request and response logging. For steps, see Request and response logging.
To create a query filter:
Make sure the following assemblies have been referenced:
Include the following using
statements:
1 2 3 4 | using Intuit.Ipp.Core; using Intuit.Ipp.Data; using Intuit.Ipp.Security; using Intuit.Ipp.QueryFilter; |
ServiceContext
is a parameter for all calls to QuickBooks Online Data Services, Platform Services, and Reporting Services.
OAuth2RequestValidator
object:
1 | OAuth2RequestValidator reqValidator = new OAuth2RequestValidator(accessToken); |
ServiceContext
class.
1 | ServiceContext context = new ServiceContext(realmId, IntuitServicesType.QBO, oauthValidator); |
Note
Note
For more information, see Authorization and Configuration.
Create an instance of QueryService
for an entity by passing the ServiceContext
created in Step 2 as the argument.
The following example shows how to create a QueryService
instance for customer entity.
1 | QueryService<Customer> customerQueryService = new QueryService<Customer>(context); |
The following example shows how to create a QueryService
instance for Invoice entity.
1 | QueryService<Invoice> invoiceQueryService = new QueryService<Invoice>(context); |
Now you are ready to create and execute queries. Proceed to the next section.
The following example queries the Customer entity. For more details and query examples, see Data queries.
1 2 | QueryService<Customer> customerQueryService = new QueryService<Customer>(context); Customer customer = customerQueryService.ExecuteIdsQuery("Select * From Customer where Id = 1").FirstOrDefault<Customer>(); |