How-to: Rename your generated CSLA properties

In the following example, I'll show you how to use the CodeSmith Generator CSLA template's powerful renaming options. Many of you might have a legacy database with those ugly prefixes, or things you wish you could refactor but just can't. Luckily, you're in luck as CodeSmith Generator is going to save the day once again! By default we will strip any invalid characters from your property names like prefixed digits etc... Please note that these methods also work for renaming class names, but there are other methods that we will cover later that are is the recommended way to specify...

How-to: Use a Stored Procedure extended property to preserve custom logic in generated CSLA code.

In the previous article on how to use the partial methods in the CodeSmith Generator CSLA templates to preserve custom code mostly focused on the code side of things. For those of you who might be using Stored Procedures might be wondering... How do I accomplish preserving my custom stored procedure logic? Don't worry, CodeSmith already though of this and didn't leave you out in the dark! The CSLA templates by default will not automatically execute the generated stored procedures but it can! To do this you need to set the AutoExecuteStoredProcedures property to True. Now, when your database...

How-to: Use partial methods to preserve custom CSLA code and promote active regeneration.

One of the best features of code generation is the reality of being able to actively generate you code while preserving custom changes. This allows you to implement custom logic while constantly making changes to your metadata and getting the latest template changes. CodeSmith Generator has worked hard on making this happen in both the PLINQO and CSLA Templates . The CSLA templates offer many partial method overrides to make your life easier. It is recommended that you place any partial methods that you implement in the non-generated partial class; this is always the ClassName.cs or ClassName.vb...

Breaking CSLA 4.0 property changes when using private backing fields.

I came across this bug last night , which was occurring right as CSLA 4 was released. It had to deal with the CodeSmith CSLA templates when you set UseMemberVariables to true. The error is quite obscure and not very intuitive as the signs of a bug are only found when you check to see if your business object IsValid. The scenario in this case is when you set a required managed property, the rules never fully evaluate the set value. A bunch of other side effects could occur as well. Here is the error you could receive: CategoryId required Expected: True But was: False Here is the code that was causing...

How-to: Upgrade your existing CodeSmith Generator CSLA templates from version 3.8 to 4.0

We recently released a new major version of the CodeSmith Generator CSLA templates that add support for many new features including Visual Studio 2010, CSLA 4.0 and Silverlight 4.0 support. They can be downloaded here . When upgrading to the templates and you are going from CSLA 3.8 to the latest CSLA 3.8.4 templates, there really aren’t any changes you need to make other than updating your CodeSmith Project File template location to point to the new version of the templates. The easiest way to do this is to open up Visual Studio and double click on the CodeSmith Project File and do a replace...

Unit testing the CodeSmith Generator CSLA generated template code

During the development of our CodeSmith Generator CSLA templates we have spent a lot time unit testing the generated code to ensure everything was working correctly. In the future we would like to generate basic CRUD unit tests for any project. We decided to unit test the PetShop database to go along with our PetShop Sample application. We have a solution both in VB and C# that can be found in (Documents\CodeSmith\Samples\v5.3\Projects\Framework-Samples\Csla) when you install CodeSmith Generator or grab the latest version from SVN . We have unit tests for all the Data Access implementations as...

CodeSmith Generator CSLA Templates v1.0 released!

Over a week ago we released our new CodeSmith Generator CSLA Templates . I highly recommend everyone that uses CSLA to try them out as they will save you a ton of time. Also you'll notice very quickly that it follows the CSLA best practices and has other features that you have been looking for like a working Data Access Layer (DAL). The best part is that you won't have to worry about learning something new (the generated code) if you are already familiar with the CSLA Framework . Noteable features: Working data access layer with concurrency support. Support for completely overriding the...

CodeSmith Generator CSLA Templates Part 2: The Quick Start

In Part 1: The Introduction was an overview of the CodeSmith Generator CSLA templates we are developing at CodeSmith . In this post, I am going to go over how to use the CSLA quick start and the new improvements resulting from customer feedback (Keep the feedback coming!). First launch CodeSmith Generator Studio and under the Frameworks node open the CSLA Folder. There are a couple of folders in the CodeSmith.CSLA folder Folder Name Description Common Contains the supporting CSLA assemblies and the Visual Studio templates to create the project. CSharp Contains the C# templates. Source Contains...

CodeSmith Generator CSLA Templates Part 1: The Introduction

I've been working on the CodeSmith Generator CSLA Templates periodically over the past few months at CodeSmith Tools . We have designed the templates from the ground up around the CSLA.NET Framework version 3.6.2. You might be thinking what's the big deal it's just another set of CSLA templates. You are mistaken, we have done a lot of research and gathered a lot of feedback. The end result is a streamlined CSLA experience that is highly customizable. To start using the CSLA templates just navigate in the Template explorer to CodeSmith.CSLA and open the Quick start template. This will...