Running a query

Your application should act as an intermediary between your users and the platform to pass in a query and receive the queried data.

Gathering specific sets of data or scoping your data should occur within queries. Typically, the analytical work is done by the Macro Language query specified by the Query object. For more information on writing queries using the Insights Platform Macro Language, see the 1010data Reference Manual.

There are two ways to run a query on the platform with the .NET SDK. You can use the Session method, RunQuery, or the Query method, RunOn. A Table object holds query results. These two methods are the same, and the one you use is your choice. For more information about the RunOn and RunQuery methods, see Session and Query in the 1010data .NET SDK Reference.

In this example, the Query object is created in the PrintTable function. The new Query object exampleQuery takes the string containing the Macro Language query and the path to the table to which the query is applied. This Macro Language query selects the first 10 rows of the table. As a best practice, longer queries should be saved in a separate file and read.

using System;
using TenTenSDK;

public class DocumentationExample {
    public static void PrintTable(Session testSession, String path) {
        Query exampleQuery = new Query(path,
                                       "<sel value=""(between(i_;1;10))""/>");
        Table resultTable = testSession.RunQuery(exampleQuery);

    public static void Main() {
        Uri gateway = new Uri("");
        String user = "[USER_NAME]";
        String pwd = "[USER_PASSWORD]";
        String path = "[TABLE_PATH]";
        Session testSession = new Session(gateway, user, pwd,
        PrintTable(testSession, path);
Note: [USER_NAME], [USER_PASSWORD], and [TABLE_PATH] are placeholders for valid Insights Platform user name, password, and table path.