Database.SqlQuery Method (Type, String, Object())

Entity Framework 5.0

Creates a raw SQL query that will return elements of the given 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 ( _
	elementType As Type, _
	sql As String, _
	ParamArray parameters As Object() _
) As IEnumerable
Dim instance As Database 
Dim elementType As Type 
Dim sql As String 
Dim parameters As Object()
Dim returnValue As IEnumerable 

returnValue = instance.SqlQuery(elementType, _
	sql, parameters)


Type: System.Type

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.IEnumerable
A IEnumerable 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.