Databases Reference
In-Depth Information
FIGURE 2.15 Stored procedure in storage section of the entity model.
In the Add Function Import dialog (see Figure 2.16), you can specify the name of the
function that will be added to the conceptual model. By default, it will match the name of
the stored procedure, but you have the option of changing it. It is common for organiza-
tions to use the Hungarian naming convention for stored procedure names, with prefixes
such as usp_ to distinguish custom stored procedures from system stored procedures,
which have prefix sp_ . However, the Hungarian notation is discouraged in .NET applica-
tions to improve readability of the code. Function import mapping option in Entity
Framework allows you to follow .NET naming conventions in the application code
without having to rename the stored procedure.
In addition to the function name, another design decision you need to make when
importing a stored procedure is to specify the type of objects returned by the stored proce-
dure. The Get Column Information button allows you to quickly see the definition of its
result set. In this case, the GetProductsToReorder procedure returns a set of Products, and
you can have the function return a collection of Product entities. If the set of columns
returned by a stored procedure does not match any of the entity types defined in the
model, you can choose the option to return a collection of complex (non-entity) objects
and have the tool automatically create a new complex type definition. Function imports
returning collections of complex objects are similar to LINQ queries that use projection to
return sets of anonymous or named objects. Similar to projection, having a stored proce-
dure return a specific set of columns helps to reduce the size of the result set but does not
take advantage of the identity tracking, which is only supported for entities.
Search WWH ::




Custom Search