ObjectContext.ExecuteFunction Method

 

Executes the given function on the default container and discard any results returned from the function.

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

NameDescription
System_CAPS_pubmethodExecuteFunction(String, ObjectParameter[])

Executes a stored procedure or function that is defined in the data source and expressed in the conceptual model; discards any results returned from the function; and returns the number of rows affected by the execution.

System_CAPS_pubmethodExecuteFunction<TElement>(String, ExecutionOptions, ObjectParameter[])

Executes the given function on the default container.

System_CAPS_pubmethodExecuteFunction<TElement>(String, MergeOption, ObjectParameter[])

Executes the given stored procedure or function that is defined in the data source and expressed in the conceptual model, with the specified parameters, and merge option. Returns a typed ObjectResult<T> .

System_CAPS_pubmethodExecuteFunction<TElement>(String, ObjectParameter[])

Executes a stored procedure or function that is defined in the data source and mapped in the conceptual model, with the specified parameters. Returns a typed ObjectResult<T> .


ObjectContext.ExecuteFunction Method (String, ObjectParameter[])

Executes a stored procedure or function that is defined in the data source and expressed in the conceptual model; discards any results returned from the function; and returns the number of rows affected by the execution.

public virtual int ExecuteFunction(
	string functionName,
	params ObjectParameter[] parameters
)

Parameters

functionName
Type: System.String

The name of the stored procedure or function. The name can include the container name, such as &lt;Container Name&gt;.&lt;Function Name&gt;. When the default container name is known, only the function name is required.

parameters
Type: System.Data.Entity.Core.Objects.ObjectParameter[]

An array of ObjectParameter objects. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Return Value

Type: System.Int32

The number of rows affected.

Exception Condition
ArgumentException

function is null or empty or function is not found.

InvalidOperationException

The entity reader does not support this function or there is a type mismatch on the reader and the function .


ObjectContext.ExecuteFunction<TElement> Method (String, ExecutionOptions, ObjectParameter[])

Executes the given function on the default container.

public virtual ObjectResult<TElement> ExecuteFunction<TElement>(
	string functionName,
	ExecutionOptions executionOptions,
	params ObjectParameter[] parameters
)

Parameters

functionName
Type: System.String

Name of function. May include container (e.g. ContainerName.FunctionName) or just function name when DefaultContainerName is known.

executionOptions
Type: System.Data.Entity.Core.Objects.ExecutionOptions

The options for executing this function.

parameters
Type: System.Data.Entity.Core.Objects.ObjectParameter[]

The parameter values to use for the function. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Return Value

Type: System.Data.Entity.Core.Objects.ObjectResult<TElement>

An object representing the result of executing this function.

Type Parameters

TElement

Element type for function results.

Exception Condition
ArgumentException

If function is null or empty

InvalidOperationException

If function is invalid (syntax, does not exist, refers to a function with return type incompatible with T)


ObjectContext.ExecuteFunction<TElement> Method (String, MergeOption, ObjectParameter[])

Executes the given stored procedure or function that is defined in the data source and expressed in the conceptual model, with the specified parameters, and merge option. Returns a typed ObjectResult<T> .

public virtual ObjectResult<TElement> ExecuteFunction<TElement>(
	string functionName,
	MergeOption mergeOption,
	params ObjectParameter[] parameters
)

Parameters

functionName
Type: System.String

The name of the stored procedure or function. The name can include the container name, such as &lt;Container Name&gt;.&lt;Function Name&gt;. When the default container name is known, only the function name is required.

mergeOption
Type: System.Data.Entity.Core.Objects.MergeOption

The MergeOption to use when executing the query.

parameters
Type: System.Data.Entity.Core.Objects.ObjectParameter[]

An array of ObjectParameter objects. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Return Value

Type: System.Data.Entity.Core.Objects.ObjectResult<TElement>

An ObjectResult<T> for the data that is returned by the stored procedure.

Type Parameters

TElement

The entity type of the ObjectResult<T> returned when the function is executed against the data source. This type must implement IEntityWithChangeTracker .

Exception Condition
ArgumentException

function is null or empty or function is not found.

InvalidOperationException

The entity reader does not support this function or there is a type mismatch on the reader and the function .


ObjectContext.ExecuteFunction<TElement> Method (String, ObjectParameter[])

Executes a stored procedure or function that is defined in the data source and mapped in the conceptual model, with the specified parameters. Returns a typed ObjectResult<T> .

public ObjectResult<TElement> ExecuteFunction<TElement>(
	string functionName,
	params ObjectParameter[] parameters
)

Parameters

functionName
Type: System.String

The name of the stored procedure or function. The name can include the container name, such as &lt;Container Name&gt;.&lt;Function Name&gt;. When the default container name is known, only the function name is required.

parameters
Type: System.Data.Entity.Core.Objects.ObjectParameter[]

An array of ObjectParameter objects. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Return Value

Type: System.Data.Entity.Core.Objects.ObjectResult<TElement>

An ObjectResult<T> for the data that is returned by the stored procedure.

Type Parameters

TElement

The entity type of the ObjectResult<T> returned when the function is executed against the data source. This type must implement IEntityWithChangeTracker .

Exception Condition
ArgumentException

function is null or empty or function is not found.

InvalidOperationException

The entity reader does not support this function or there is a type mismatch on the reader and the function .