Query in Multiple Categories |
Scroll |
TheMultiQuery allows you to specify and execute queries in multiple categories. It can be seen as a list of TheQuery objects returning a list of TheQueryResult objects. .
1 |
Connect to the Thereforeā¢ server (see "Server - Connect and Disconnect" for Details) |
2 |
Declare and initialize a new TheMultiQuery. |
3 |
Create and add two or more queries (see "Query in One Category" for more details on query specification). |
4 |
Execute the multi-query on the server. |
5 |
Optional. Display multi-query definition and results. |
Requirements and Assumptions: If these assumptions do not apply to your system or configuration please replace them with appropriate values when copying the code samples below. Visual Basic Imports Therefore.API '...
' 1. Connect to the Thereforeā¢ server Dim server As New TheServer server.Connect(TheClientType.CustomApplication)
' 2. Create a new multi-query Dim multiQuery As New TheMultiQuery
' 3. Create and add two or more queries Dim query As New TheQuery query.Category.Load(5, server) query.SelectFields.AddAll() query.Conditions.Add("Supplier", "A*") query.OrderByFields.Add("InvoiceNo") multiQuery.Add(query)
Dim query2 As New TheQuery query2.Category.Load(4, server) query2.SelectFields.AddAll() multiQuery.Add(query2)
' 4. Execute the multi-query Dim multiResults As TheMultiQueryResult = multiQuery.Execute(server)
' Optional 5. Display multi-query definition and results in MessageBox System.Windows.Forms.MessageBox.Show( multiQuery.ToString() _ + vbNewLine + "---------------------------------------------------" _ + vbNewLine + vbNewLine + multiResults.ToString() ) C# using Therefore.API; //...
// 1. Connect to the Thereforeā¢ server TheServer server = new TheServer(); server.Connect(TheClientType.CustomApplication);
// 2. Create a new multi-query TheMultiQuery multiQuery = new TheMultiQuery();
// 3. Create and add two or more queries TheQuery query = new TheQuery(); query.Category.Load(5, server); query.SelectFields.AddAll(); query.Conditions.Add("Supplier", "A*"); // using the column query.OrderByFields.Add("InvoiceNo"); multiQuery.Add(query);
TheQuery query2 = new TheQuery(); query2.Category.Load(4, server); query2.SelectFields.AddAll(); multiQuery.Add(query2);
// 4. Execute the multi-query TheMultiQueryResult multiResults = multiQuery.Execute(server);
// Optional 5. Display multi-query definition and results in MessageBox System.Windows.Forms.MessageBox.Show (multiQuery.ToString() + "\r\n---------------------------------------------------\r\n\r\n" + multiResults.ToString()); |
Advanced SQL Features Advanced SQL features such as grouping and joining tables are not yet supported by the Thereforeā¢ system.
Performance Note Combining several TheQuery instances in an TheMultiQuery and executing them together is more efficient than executing the queries individually. |