Creating and Editing Methods

Methods are the ObjectContext class methods, based on stored procedures. Available methods are visible in the Model Explorer window.

 

ExpandedToggleIcon        Creating and Editing Methods

Methods can be added to the model either by dragging stored procedures (or Oracle packages) from the Database Explorer, or by manually creating a new method.

To create a new method, use one of the following ways:

Press the ALT+M shortcut keys.
Right-click the Methods node in the Model Explorer window and select the New Method menu item.

Any of these actions opens the Method Editor dialog box where method parameters and the return type should be specified. A method can have a scalar return type, return complex types, entities, or return no value. If a method should return several resultsets, you can create a method, returning several entities or complex types. To do this, select Value Types in Method Editor, then select the required type in the drop-down list of the first row in the Value Types grid. Then the second row will be displayed - select the next type in it and so on.

Methods can be created from stored procedures, stored functions and command text. The command text functionality allows creating functions in the storage part of the model on the basis of custom SQL queries that are not stored in the database.

To edit an existing method, right-click the required method in the Model Explorer window, and select Edit in its context menu. This will call the Method Editor dialog box that allows you to customize method properties, change the list of parameters, etc.

Sometimes you may need to use different names for entity properties and recordset columns. You can change mapping of the value type corresponding to the method and dataset columns by right-clicking the method node and then clicking Result Mapping Details. In the displayed Result Mapping Details dialog box, you can change dataset column names. This option is available only for Entity Framework models starting from EF v4 and later, and for functions that return entity or complex type. It isn't available for functions, returning multiple resultsets.

Refer to the corresponding sections for the examples showing how to work in Entity Developer with the most frequent cases of using methods based on command text, stored procedures or functions.

 

ExpandedToggleIcon        Entity Framework Method in the Conceptual and Storage Models

The following context menu option is available for Entity Framework methods:

Select Storage - looks for a function in the Storage part, to which the method in the Conceptual model is mapped.

 

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.