Export (0) Print
Expand All

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)

'Declaration
Public Function SqlQuery ( _
	elementType As Type, _
	sql As String, _
	ParamArray parameters As Object() _
) As IEnumerable
'Usage
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)

Parameters

elementType
Type: System.Type

The type of object returned by the query.

sql
Type: System.String

The SQL query string.

parameters
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.

Show:
© 2014 Microsoft