[]
Creates a C1DataEngine query from a JSON string.
public static object CreateQueryFromJsonString(Workspace workspace, string json)
Type | Name | Description |
---|---|---|
Workspace | workspace | The C1DataEngine Workspace object in which the query will be created. |
string | json | The JSON string that describes query elements such as tables, columns, and range conditions. |
Type | Description |
---|---|
object | A dynamic object representing the query. The caller is responsible for executing it. |
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();