Dynamics Mobile provided by Mobile Affairs Ltd. | 1712 Sofia, Bulgaria, Alexander Malinov 51 | sales@dynamicsmobile.com
Overview
The LiveLinkQuery class provides methods to execute data queries against the backend system. It is used for the same purposes as the good, old database SQL statements.
LiveLinkQuery class provides methods to select, insert, update and delete business objects from the connected backed system. The following types of backend systems are available:
Application Area (e.g. data from backend apps)
Connected system ( Microsoft Dynamics 365 FO, Microsoft Dynamics 365 Business Central and others)
The developer of the application can use the LiveLinkQuery class without specifying connectivity parameters. The connectivity parameters will be automatically extracted from the application user role.
Don't instantiate directly instances of the LiveLinkQuery class.
LiveLinkQuery instances are created through a call to the liveLinkQuery() method of the BusinessObjectBase assessor.
See also BusinessObjectBase.liveLinkQuery() method
fields method sets the list of the fields to be returned by the executeSelect method of LiveLinkQuery. It provides functionality similar to the SELECT clause in a sql statement.
fields: Array<string>
array containing the name of the business object members to be returned by executeSelect method.
DbQuery instance, allowing methods chaining.
import {DbQuery} from'@dms'import {Customer} from'@dms-bo'constquery=Customer.liveLinkQuery();//define only 3 fields to be returnedquery.fields(['Id','Name','City']);//method chaining - e.g. calling several method on a single linequery.fields(['Id','Name','City']).filter("Id='123'");
filter(filterExpression: string): DbQuery<T>
Allows the developer to define a filter to be applied, when using executeSelect() method. The filter expects the same syntax as WHERE clause in sql statement.
filterExpression: string
the filter to be applied during a call to executeSelect method
DbQuery instance, allowing method chaining.
import {DbQuery} from'@dms'import {Customer} from'@dms-bo'constquery=Customer.liveLinkQuery();//equalquery.filter("Id=1123'");//greater thanquery.filter("Revenue > 6000");//more complex filter with parentess query.filter("((Revenue > 6000 or Revenue=0) and (City='Sofia'))");constresult=awaitquery.executeSelect();//method chaining - e.g. calling several method on a single lineconst result2 = await query.fields(['Id','Name','City','Revenue']).filter("City='Dubai'and Revenue>1234").executeSelect();
limit(maxRecords: number): DbQuery<T>
Allows the developer to limit the number of the records returned by the query.
max - maximum number of records to be returned by the executeSelect() method
DbQuery instance, allowing method chaining.
import {DbQuery} from'@dms'import {Customer} from'@dms-bo'constquery=Customer.liveLinkQuery();//limit to 100 recordsquery.max(100);constresult=awaitquery.executeSelect();
page(index: number): DbQuery<T>
Allows the developer to define the page number to be returned in page indexing scenarios. This make sense only if the limit() method was used.
index - the page index number to be returned by the executeSelect() method
DbQuery instance, allowing method chaining.
import {DbQuery} from'@dms'import {Customer} from'@dms-bo'constquery=Customer.liveLinkQuery();//limit to 100 recordsquery.max(100);//select second page , e.g. records from 100th to 199thquery.page(2);constresult=awaitquery.executeSelect();
group(groupExpression: string): DbQuery<T>
Allows the developer to define a query group expression to be used. This is the same as in the GROUP BY clause in Sql
groupExpression - the actual group expression to be applied during the execution of the executeSelect() method
DbQuery instance, allowing method chaining.
import {DbQuery} from'@dms'import {Customer} from'@dms-bo'constquery=Customer.liveLinkQuery();query.group('City, Country');constresult=awaitquery.executeSelect();//method chaining - e.g. calling several method on a single lineconstresult2=awaitquery.group('City, Country').executeSelect();
Allows the developer to define a aggregate expression to be used. This is the same as in aggregates(max, count, min , avg, ...) in Sql Note that the aggregate() method can NOT be used together with fields() method - e.g. the developer must either fields() or aggregate() methods
aggregateExpression - the actual aggregate expression to be applied during the execution of the executeSelect() method
DbQuery instance, allowing method chaining.
import {DbQuery} from'@dms'import {Customer} from'@dms-bo'constquery=Customer.liveLinkQuery();query.aggregate('max(Revenue) as revenue, count(*) as cnt');constresult=awaitquery.executeSelect();//method chaining - e.g. calling several method on a single lineconst result2 = await query.group('City, Country').aggregate('max(Revenue) as revenue, count(*) as cnt').executeSelect();
sort(sortExpression: string): DbQuery<T>
Allows the developer to define a sort expression to be used. This is the same as in ORDER BY clause in Sql
sortExpression - the actual sorting expression to be applied during the execution of the executeSelect() method
DbQuery instance, allowing method chaining.
import {DbQuery} from'@dms'import {Customer} from'@dms-bo'constquery=Customer.liveLinkQuery();query.sort('Revenue asc');constresult=awaitquery.executeSelect();//method chaining - e.g. calling several method on a single lineconstresult2=awaitquery.fields(['City','Country']).sort('Revenue asc').executeSelect();
executeSelect(): Promise<BusinessObjectBase:T>
executeSelect method performs the actual query execution and returns array of objects, which extends class BusinessObjectBase.