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

<< Click to Display Table of Contents >>

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

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

Executes a query against the database, with the specified parameters and returns a list of dynamic objects with the query results. The query must be a valid SQL command that can be executed against the database.

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, _
 parameters As IDictionary _
) As List(Of Object)

C#

public List<Object> GetListFromQuery(

 string query,
 IDictionary parameters
)

Visual C++

public:

List<Object^>^ GetListFromQuery(
 String^ query,
 IDictionary^ parameters
)

JavaScript

function getListFromQuery(query, parameters);

Parameters

query

Type: System.String
The SQL query to execute.

parameters

Type: System.Collections.IDictionary
A dictionary of parameters to use in the query.

Remarks

The query is a standard parameterized query like

 

Copy imageCopy Code

SELECT * FROM DOCUMENT WHERE ID = @id AND DESCRIPTION = @description AND CREATION_DATE = @creationdate

 

The parameters dictionary must contain the parameter names and values, with or without the '@' symbol. For example:

 

Copy imageCopy Code

 Dim parameters As New Dictionary(Of String, Object)()

 parameters("id") = 1

 parameters("description") = "Sample Description"
 parameters("creationdate") = DateTime.Now

 

Or in PowerShell:

 

Copy imageCopy Code

 $parameters = @{

     id = 1

     description = "Sample Description"
     creationdate = [datetime](Get-Date)
 }

The format of the query and the parameters is the standard one for parameterized queries in ADO.NET, with '@' as prefix for parameters in the query, and a dictionary of parameter names and values passed to the method. The parameters type are inferred automatically and correctly managed in most of the standard scenarios.

See Also

Database Class

Database Members

GetListFromQuery Overload

MwPDMApi Namespace