To Call query in Axapta by code you can try below code. You need to create query in aot query node then pass query using querystr method in queryrun object.
QueryRun queryRun;
int cnt;
;
queryRun = new QueryRun(queryStr(Query1));
if (queryRun.prompt())
{
while (queryRun.next())
{
cnt++;
}