Database.SqlQuery(Of TElement) Method (String, Object())

Entity Framework 5.0

Creates a raw SQL query that will return elements of the given generic type. The type can be any type that has properties that match the names of the columns returned from the query, or can be a simple primitive type.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

Public Function SqlQuery(Of TElement) ( _
	sql As String, _
	ParamArray parameters As Object() _
) As IEnumerable(Of TElement)
Dim instance As Database 
Dim sql As String 
Dim parameters As Object()
Dim returnValue As IEnumerable(Of TElement)

returnValue = instance.SqlQuery(sql, parameters)

Type Parameters


The type of object returned by the query.


Type: System.String

The SQL query string.

Type: System.Object()

The parameters to apply to the SQL query string.

Return Value

Type: System.Collections.Generic.IEnumerable(Of TElement)
A IEnumerable(Of T) object that will execute the query when it is enumerated.

The specified type does not have to be an entity type. The results of this query are never tracked by the context even if the type of object returned is an entity type. Use the SqlQuery(String, Object()) method to return entities that are tracked by the context.