Home > Developing Using CodeFluent Entities, Oracle Database, SQL Server, SQLAzure > Mapping a Method Onto a Stored Procedure

Mapping a Method Onto a Stored Procedure


Doing something very specific using a stored procedure? Yet, you’d like to access this stored procedure from your Object Model so all upper layers can use this stored procedure?

Since the stored procedure is one of your own and was not generated by CodeFluent Entities, you’re going to have to link the object model with it.

Say for instance you have a very specific stored procedure named “sp_GetTransactions”, in your entity defining a transaction, you could create the following method:

<cf:method name=”GetTransactions” persistentName=”sp_GetTransactions” body=”load(string filter)” cfps:produce=”false” />

Note: The “cfps:” is the SQL Server Producer namespace (xmlns:cfps=”http://www.softfluent.com/codefluent/producers.sqlserver/2005/1”).

The cf:method declaration reads as follows:

Create a method named GetTransactions corresponding to the sp_GetTransactions method in the persistence layer, which is a load method taking a filter string as parameter, however the SQL Server Producer should not produce it.

Note: the filter string is to illustrate how to set up parameters, it is absolutely not mandatory.

All producers will generate the corresponding code except the SQL Server Producer, which is exactly what we want since we provided the stored procedure ourselves.

Sweet isn’t it?

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s