Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

We have been working on a major update to the Generator CSLA Templates to support Views and Stored Procedures as well as CSLA 4.3. The following document The following section will show you how you can take advantage of generating against stored procedures and views by updating your existing templates. Please note that the latest CSLA templates require Generator 6.0.3!

Updating the Entities template output

The quickest way to add support for generating against a view or stored procedure is to update the entities template output by using Manage Outputs. Once the Entities template output is open, .

We will start by opening by going back into our Entities.csp Edit Output dialog as shown in the previous step. You can open this dialog by right clicking the Entities.csp template and select Manage Outputs. After the manage outputs dialog comes up double click on the Entities.cst item.

Once the Entities Edit Output dialog is opened. You will need to check the IncludeFunctions and IncludeViews properties as shown below.

Image Removed

When we set these two properties to true, the templates will enable stored procedure and view support.

Image Added

Since earlier versions of the templates didn't support views and stored procedures. We decided against breaking backwards compatibility with the Entities output, this saves you from having to reconfigure all of your outputs in the new release. To select what Business Object Type a specific view or stored procedure should be generated as, you will need to add an Extended Property to the view or stored procedure.when upgrading. But this also prevents you from selecting what business object type a view and stored procedure will be generated as. Since you can't choose a view or stored procedure inside of the Entities.csp Edit Output screen. You might be wondering how do I configure my business object types then? The solution is to control this by adding an Extended Property to your stored procedure or view!

Here is a list of the valid Extended Property names that can be added to a view or stored procedure.

Extended Property Name Extended Property ValueBusiness Object Type
DynamicRoot Dynamic Root
EditableChild Editable Child
EditableRoot Editable Root
ReadOnlyChild Read Only Child
ReadOnlyRoot Read Only Root
SwitchableObject Switchable Object
DynamicRootList Dynamic Root List
EditableRootList Editable Root List
DynamicListBase Dynamic List Base
EditableChildList Editable Child List
ReadOnlyList Read Only List
ReadOnlyChildList Read Only Child List
NameValueList Name Value List

After you have configured this added an extended property, all you need to do is regenerate !

Adding a custom output

One can also generate against a view or stored procedure by adding a new template output to a CodeSmith Generator Project File. Once you select "Add Output" browse for one of the 14 business object master templates located inside of the CSharp\ BusinessLayer \ or VisualBasic\BusinessLayer\ folders. Next, populate one of the SourceCommand, SourceTable or SourceView properties to generate a business object against this datasource.

Image Removed

Finally, click save and  regenerate!and watch your new business objects be added to the project!

Next: Where to go from here