This walkthrough depicts a scenario where the user is provided with a user interface to select the table, table fields and operators, which would be used to create the query and display the query results using the client side controls. Note that the C1DataEngine library includes a class named QueryFactory, which provides methods to create a C1DataEngine Query from JSON string or RuntimeQuery objects. This is helpful when we need to choose the query fields and operators at runtime. The selected values can be used to create the query using the QueryFactory class.
The GIF below depicts the DataEngine in action while extracting the count of animals (species-wise) from a dataset of Pet Licenses issued for the city of Seattle.
To learn how to create queries using QueryFactory in detail, follow the steps given below:
C1.DataEngine.LicenseManager.Key = “XXXXXX”;
To accomplish the same, add a custom js file named “CustomGridEditor” to the js folder found under the wwwroot folder in the project’s root folder. Refer the code snippet below:
<script type="text/javascript" src="~/js/CustomGridEditor.js"></script>
<script type="text/javascript" src="~/js/CustomGridEditor.js"></script>
The OnGetAsync method will be used to fetch the query results and send the same back to the client side as a JSON response:
The OnPostAsync method will be used to handle the query data send from the client side. The JSON query object is handled as a RuntimeQuery object on the server side. The method would create the query on the server side and execute the same to create the result tables.