Database.SqlQuery<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 IEnumerable<TElement> SqlQuery<TElement>(
	string sql,
	params Object[] 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<TElement>
A IEnumerable<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.