Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

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

Namespace:  System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)
public ObjectResult<TElement> ExecuteFunction<TElement>(
	string functionName,
	params ObjectParameter[] parameters
)

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.

Parameters

functionName
Type: System.String

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

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

An array of ObjectParameter objects.

Return Value

Type: System.Data.Objects.ObjectResult<TElement>
An ObjectResult<T> for the data that is returned by the stored procedure.
ExceptionCondition
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.

The ExecuteFunction method is a helper method that is used to execute stored procedures or functions that are defined in the data source and expressed in the conceptual model. The Entity Data Model tools generate a method for each FunctionImport Element in the conceptual model. These methods call a strongly-typed ExecuteFunction to return a typed ObjectResult<T>. For more information, see Application Code using Stored Procedures (Enity Framework).

All parameters for the function are required in the parameters array and all types are checked against the metadata for the import function, including the type of the function itself. null values are permitted for CLR value types. Parameter validation is performed by the provider.

The ExecuteFunction method uses the MergeOption value of AppendOnly. Therefore, if an object already exists in the object context, it will not be loaded from the data source.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.