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

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

    Parameters

    workspace
    The C1DataEngine Workspace object in which the query will be created.
    query
    The RuntimeQuery object 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 RuntimeQuery object:

    RuntimeQuery runtime = new RuntimeQuery(); List<string> tables = new List<string>(); List<RuntimeColumn> columns = new List<RuntimeColumn>(); List<RuntimeRangeCondition> range = new List<RuntimeRangeCondition>(); List<RuntimeRangeExpression> expr = new List<RuntimeRangeExpression>(); tables.Add("Products"); columns.Add(new RuntimeColumn("ProductColor"); columns.Add(new RuntimeColumn("ProductID", "Count", "Count"); expr.Add(new RuntimeRangeExpression("Gte", 100); range.Add(new RuntimeRangeCondition("ProductPrice", expr.ToArray()); runtime.name = "ProductsByColor"; runtime.tables = tables.ToArray(); runtime.columns = columns.ToArray(); runtime.range = range.ToArray(); dynamic query = CreateQueryFromRuntimeQuery(workspace, runtime); query.Query.Execute();
    See Also