DataEngine for .NET Standard | ComponentOne
C1.DataEngine.Api Assembly / C1.DataEngine Namespace / QueryFactory Class / CreateQueryFromJsonString Method
The C1DataEngine Workspace object in which the query will be created.
The JSON string that describes query elements such as tables, columns, and range conditions.

In This Topic
    CreateQueryFromJsonString Method
    In This Topic
    Creates a C1DataEngine query from a JSON string.
    Syntax
    'Declaration
     
    Public Shared Function CreateQueryFromJsonString( _
       ByVal workspace As Workspace, _
       ByVal json As String _
    ) As Object
    public static object CreateQueryFromJsonString( 
       Workspace workspace,
       string json
    )

    Parameters

    workspace
    The C1DataEngine Workspace object in which the query will be created.
    json
    The JSON string that describes query elements such as tables, columns, and range conditions.

    Return Value

    A dynamic object representing the query. The caller is responsible for executing it.
    Remarks

    Typically, queries are created in C# code using anonymous objects, as in the following example:

    dynamic products = workspace.table("Products"); dynamic query = workspace.query("ProductsByColor", new { products.ProductColor, Count = Op.Count(products.ProductID), _range = products.ProductPrice.Gte(100) }); query.Query.Execute();

    Applications that allow end users to create ad-hoc queries can use this method to create a query from a JSON string:

    string json = @"{ "name": "ProductsByColor", "tables": [ "Products" ], "columns": [ { "names": [ "ProductColor" ] }, { "names": [ "ProductID" ], "op": "Count", "alias": "Count" } ], "range": [ { "name": "ProductPrice", "expr": [ { "op": "Gte", "value": "100" } ] } ] }"; dynamic query = CreateQueryFromJsonString(workspace, json); query.Query.Execute();
    See Also