Command Text With Multiple Resultsets

This topic describes creating a method in Entity Developer Entity Framework model, which will execute a parameterized query returning the table records that satisfy the query condition as the list of corresponding entity objects.

For this, perform the following steps:

1.This example requires adding either two entities, or two complex types; we add the Department and Employee entities in this example. They can be created either manually, or dropped on the design area from the Database Explorer window.
2.In the Model Explorer window right-click the Stored Procedures node, select the Add submenu and then select New Command Text.
3.In the Command Text Editor dialog specify the stored procedure name and the SQL script:

images_command-text-multi-resultsets-general-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, i.e. the two tables we have added to the model:

images_command-text-multi-resultsets-method-general-EF

7.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 GetDeptsAndEmpsMultipleResult GetDeptsAndEmps ()

 

Visual Basic:

Public Function GetDeptsAndEmps () As GetDeptsAndEmpsMultipleResult

 

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.