Command Text Without Result

This topic describes how to create a method, mapped to a Command Text, which will execute a parameterized INSERT statement for inserting a row into a table, in a Entity Developer Entity Framework model.

For this, perform the following steps:

1.In the Model Explorer window right-click the Stored Procedures node, select the Add submenu and then select New Command Text.
2.In the Command Text Editor dialog specify the stored procedure name and the SQL script:

images_command-text-without-general-EF

3.Customize the parameters:

images_command-text-without-params-EF

4.Click OK.
5.Right-click the created stored procedure and select Create Method in the context menu.
6.In the Method Editor dialog box specify the required Return Type:

images_command-text-without-method-general-EF

7.Customize the parameters:

images_command-text-without-method-params-EF

8.Click OK.

The method is created.

As a result of code generation for the model, the corresponding method of the model context will be generated having a signature close to the relevant stored procedure:

 

C#:

public void InsertIntoDepartment (global::System.Nullable<int> deptno, string dname, string loc)

 

Visual Basic:

Public Sub InsertIntoDepartment (ByVal deptno As Global.System.Nullable(Of Integer), ByVal dname As String, ByVal loc As String)

 

Now it is possible to use this query in the application with the help of method wrapper. This allows working with the query with all possible convenience, as wrapper methods are strongly typed, are found by IntelliSense and have the corresponding signature.

 

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.