Skip to main content

Using Execute Query on the Form

To make the use of the ExecuteQuery method on the Form, which is faster than ServiceAPI, and the return result understandable.

We must create a Class according to the types of columns under the Columns tab in the relevant datasource we will use. This will provide ease of use of the data coming to us.

Use Case

var res = ExecuteQuery```<```Class```>```(DataSourceName, new[] { new { ParameterKey = ParameterValue } });

Sample Class

public class Class
{
public int ID { get; set; }
public string USERNAME { get; set; }
public string FIRSTNAME { get; set; }
}

Auxiliary Method

public List```<```T```>``` ExecuteQuery```<```T```>```(string queryName, object[] queryArguments) where T : class, new()
{
var queryResult = (List```<```Dictionary```<```string, object```>``````>```)((DataSourceResponse)ExecuteQuery(queryName, queryArguments). Result.QueryResult). Result;
List```<```T```>``` typedList = new List```<```T```>```();
foreach (var dictionary in queryResult)
{
T typed = new T();
foreach (var kvp in dictionary)
{
if (kvp. Value is not DBNull)
{
Typed. GetType(). GetProperty(kvp. Key). SetValue(typed, kvp. Value);
}
}
typedList.Add(typed);
}
return typedList;
}