xpo-devexpress-dot-xpo-dot-session-dot-getobjectsfromquery-1-x28-system-dot-string-system-dot-string-system-dot-object-x29.md
This method executes a raw SQL query string. Always validate, sanitize, or parameterize externally supplied SQL query strings to prevent unauthorized access to sensitive information.
Executes a SQL query and returns its result set as a collection of objects of a non-persistent type specified by the generic type parameter.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
public ICollection<T> GetObjectsFromQuery<T>(
string sql,
string[] parameterNames,
object[] parameterValues
)
Public Function GetObjectsFromQuery(Of T)(
sql As String,
parameterNames As String(),
parameterValues As Object()
) As ICollection(Of T)
| Name | Type | Description |
|---|---|---|
| sql | String |
Specifies an SQL statement.
| | parameterNames | String[] |
Specifies parameter names.
| | parameterValues | Object[] |
An array of objects specifying parameters to pass to the database server along with the query.
|
| Name | Description |
|---|---|
| T |
The type of objects returned by the method. A class that implements this type sould be decorated with NonPersistentAttribute.
|
| Type | Description |
|---|---|
| ICollection<T> |
A collection of non-persistent objects of the specified type.
|
This method does the following:
Note
The GetObjectsFromQuery<T> method throws an exception if the members list includes any of the following object members:
To learn more about executing SQL statements in XPO, refer to Direct SQL Queries.
Note
The GetObjectsFromQuery method sends statements directly, so the correct statement syntax and parameter names format depends on a particular database server.
See Also
GetObjectsFromSprocParametrized
GetObjectsByKeyFromQuery(XPClassInfo, Boolean, String)
GetObjectsByKeyFromSproc(XPClassInfo, Boolean, String, OperandValue[])
GetObjectsByKeyFromSprocParametrized(XPClassInfo, Boolean, String, SprocParameter[])