.NET Framework Class Library
Database.GetListFromQuery Method (String)

<< Click to Display Table of Contents >>

Navigation:  MwPDMApi Namespace > Database Class > Database Methods > GetListFromQuery Method  >

.NET Framework Class Library
Database.GetListFromQuery Method (String)

Given a query, returns a list of dynamic objects with the query results.

Namespace: MwPDMApi
Assembly:  MwPDMApi (in MwPDMApi.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

Visual Basic

Public Function GetListFromQuery ( _

 query As String _
As List(Of Object)

C#

public List<ObjectGetListFromQuery(

 string query
)

Visual C++

public:

List<Object^>^ GetListFromQuery(
 Stringquery
)

JavaScript

function getListFromQuery(query);

Parameters

query

Type: System.String
The query to execute. It must return a single recordset

Return Value

A list of objects whose property names are specified in the column name in the query

Remarks

Each object will have a property for each column in the query with the name of the column set in the query.

Examples

For example consider the following PowerShell piece of code:

 

Copy imageCopy Code

 $fn = $app.Messages().LookUp("NAME_FIELD_FILE_NAME")

 $fd = $app.Messages().LookUp("NAME_FIELD_FILE_DIRECTORY")

 $uid = $app.Messages().LookUp("NAME_FIELD_UNIQUE_ID")
 $table = $app.Messages().LookUp("NAME_DOCUMENT_TABLE")
 $query = "SELECT $fd as Directory, $fn as FileName, COUNT($fn) AS QTY FROM $table GROUP BY $fd, $fn"
 $list = $db.GetListFromQuery($query)
 foreach ($doc in $list) {
     Write-Host $doc.FileName
     Write-Host $doc.Directory
     Write-Host $doc.QTY
 }

The $doc object in the foreach loop will have the properties FileName, Directory and QTY, which are exactly the column names specified in the query with the AS keyword.

We suggest to use the AS keyword to give a name to the columns in the query, to avoid difficulties with the localized databases.

See Also

Database Class

Database Members

GetListFromQuery Overload

MwPDMApi Namespace