Database.SqlQuery Method

Definition

Overloads

SqlQuery(Type, String, Object[])

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

SqlQuery<TElement>(String, Object[])

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

SqlQuery(Type, String, Object[])

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

public System.Collections.IEnumerable SqlQuery (Type elementType, string sql, params object[] parameters);
member this.SqlQuery : Type * string * obj[] -> System.Collections.IEnumerable
Public Function SqlQuery (elementType As Type, sql As String, ParamArray parameters As Object()) As IEnumerable

Parameters

elementType
Type

The type of object returned by the query.

sql
String

The SQL query string.

parameters
Object[]

The parameters to apply to the SQL query string.

Returns

A IEnumerable object that will execute the query when it is enumerated.

Applies to

SqlQuery<TElement>(String, Object[])

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

public System.Collections.Generic.IEnumerable<TElement> SqlQuery<TElement> (string sql, params object[] parameters);
member this.SqlQuery : string * obj[] -> seq<'Element>
Public Function SqlQuery(Of TElement) (sql As String, ParamArray parameters As Object()) As IEnumerable(Of TElement)

Type Parameters

TElement

The type of object returned by the query.

Parameters

sql
String

The SQL query string.

parameters
Object[]

The parameters to apply to the SQL query string.

Returns

IEnumerable<TElement>

A IEnumerable<T> object that will execute the query when it is enumerated.

Applies to