<StoredProcedure> Element

Maps a member to a stored procedure call in the underlying relational database system.

<Member name="member" [signature="parameterList"]

        StoredProcedure="stored-procedure" />

or

<Member name="member" [signature="parameterList"]>

        <StoredProceduredbName="stored-procedure"

               [catalogName="catalog"]

               [owner="database-user"]

               [package="package"]>

               [<Parameters>

                       (<Paramname="c#ParamName" [dbName="dbParamName"]

                       [databaseTypeModifiers])+

               </Parameters>]

               [<ResultcursorParameterName="ref-cursor-parameter">

                       result-binder-element

               </Result>]

               [<Source>stored-procedure-source-code</Source>]

        </StoredProcedure>
</Member>

 

member: A member name specifying a property or a method.

parameterList: A comma separated list of parameters to specify the member’s desired overload.

stored-procedure: An identifier specifying the name of the stored procedure to call.

catalog: A catalog (database) name in the underlying relational database system. If the catalog is not specified, the default catalog of the DataDomain is used.

database-user: A database user name (schema name in Oracle databases). If the database-user is not specified, the default database user is used.

package: A database package that contains the stored procedure. If the package is not specified, the procedure will be called without package qualifier. This attribute is used by database providers (currently Oracle) that support packages. The attribute is ignored for other providers.

c#ParamName: Name of a member parameter to explicitly map to the stored procedure parameter dbParamName.

dbParamName: Name of a stored procedure parameter the C#ParamName is mapped to.

databaseTypeModifiers: An optional list of database type modifiers that change the type of the stored function parameter. The default mapping for the type of the parameter, the object instance or the return type is used if no modifier is specified. The defaults can be found in the description of Database Type Modifiers.

ref-cursor-parameter: The parameter name of the output ref cursor for database providers that can return recordset result using ref cursor parameters (currently Oracle). The attribute is ignored for other providers.

result-binder-element: An element specifying how the result of the stored procedure is bound to the return type of the member. The element can be one of the following: <ScalarResultBinder/>, <PersistentResultBinder/> or <CompositeResultBinder/>.

stored-procedure-source-code: The stored procedure’s source code can optionally be specified in the mapping file to include it in the version control system with the other project assets. When specified, stored-procedure-source-code is included in the DDL script generated by Genome. When configured in the DataDomain schema project options, the stored-procedure is also automatically deployed to the specified database with each DataDomain schema project compilation.

Remarks

If the <Parameters/> element is omitted, the parameter names of the stored-procedure are matched to the parameter names of the member. You can also map only selected parameters of the stored-procedure using the <Parameters/> element (remaining parameters will be matched by name).

Out parameters of the stored-procedure can be mapped to out or ref parameters of the member method.

<ScalarResultBinder/> is used to map a column to a scalar result (e.g. Set<int>).

<PersistentResultBinder/> is used to map a set of columns to a persistent result (e.g. Set<Customer>).

<CompositeResultBinder/> is used to map a set of columns to an arbitrary result type (e.g. Set<int[]>, Set<object[]>, Set<MyTransientType>).

Note that included stored procedure source code is not checked during compile time unless automatic database schema update is enabled in the DataDomain schema project.

Examples

Using default parameter mapping

Mapping a method that returns void to a stored procedure:

public abstract void IncreaseStock(Guid productId, int amount);

can be mapped as

<Member name="IncreaseStock" signature="Guid, int" StoredProcedure="IncreaseStock" />

or as

<Member name="IncreaseStock" signature="Guid, int">

        <StoredProcedure dbName="IncreaseStock" />

</Member>

The mapping above assumes the existence of a stored procedure IncreaseStock with the parameters @productId and @amount in the database.

Explicitly mapping parameters

The same method can be mapped by using explicit parameter mapping:

<Member name="IncreaseStock" signature="Guid, int">

        <StoredProcedure dbName="IncreaseStock">

               <Parameters>

                       <Param name="productId" dbName="Id" />

                       <Param name="amount" dbName="value" Size="4" />

               </Parameters>

        </StoredProcedure>

</Member>

The mapping above assumes the existence of a stored procedure IncreaseStock with the parameters @Id and @value in the database.

 

Including stored procedure source code in mapping files

To maintain the source code of a stored procedure versioned with the mapping file, it can be included by using the <Source/> element:

<Member name="IncreaseStock" signature="Guid, int">

        <StoredProcedure dbName="IncreaseStock">

               …

               <Source>

                       CREATE PROCEDURE IncreaseStock(

                               @productId uniqueidentifier,

                               @amount int)

                       AS

                       BEGIN

                               -- procedure body

                      END

               </Source>

        </StoredProcedure>

</Member>

 

Requirements

Editions:Professional, Evaluation, Express

Database Platforms:Microsoft SQL Server 2000, Microsoft SQL Server 2005, Oracle 9i Release 2, Oracle 10g Release 2

See also

<ScalarResultBinder/> element, <PersistentResultBinder/> element, <CompositeResultBinder/> element



<ScalarResultBinder> Element