Quite a few people have asked me about the effort that will be required to move an application from CSLA .NET 1.0 to CSLA .NET 2.0. The list of changes in the change log can look daunting after all…
Fortunately most of the changes in the change log are internal – they don’t directly impact your code in a business class all that much, at least for code written using more recent versions of the framework (1.3 or higher).
In fact, the closer your code is to version 1.51 (the current version) the easier the port will be. The closer to the original 1.0 version in the books the harder.
The three big change areas are generics, BrokenRules and the DataPortal.
Generics mean there are new and different base classes from which you inherit. In most cases changing to the new base class means removing some now unneeded code from your business class. The following table lists the base classes:
T = your business object type
BusinessListBase(Of T, C)
T = your collection type
C = child object type
NameValueListBase(Of K, V)
K = type of the key or name
V = type of the value
T = child object type
The only place where you need to add code is BusinessBase(Of T), where there’s a new GetIdValue method you must implement (typically with one line of code). In all cases you will remove code such as the System.Objects overrides region and tons of code in collections.
A much bigger changes is that BrokenRules has been replaced by ValidationRules and now only supports the idea of rule methods. The BrokenRules.Assert() concept is gone. This will be the biggest change for most people, as all Assert calls must be converted to rule methods. Fortunately that's not terribly hard, but it is work.
DataPortal used to call DataPortal_Update, forcing you to write a nested If..Then statement inside DataPortal_Update. It now calls DataPortal_Insert, DataPortal_Update or DataPortal_DeleteSelf as appropriate. So now you write 3 methods instead of 1, but each method is very focused and requires no conditionals. Also, DataPortal now calls MarkNew and MarkOld automatically so you don't need to make those calls (or forget to make them like I typically did...).
The end result is that all properties in a BusinessBase(Of T) business object will now look like this:
private string _name = string.Empty;
public string Name
throw new System.Security.SecurityException(
"Property get not allowed");
if (_name != value)
_name = value;
"Property set not allowed");
Private mName As String = ""
Public Property Name() As String
If CanReadProperty() Then
Throw New System.Security.SecurityException( _
"Property get not allowed")
Set(ByVal value As String)
If CanWriteProperty() Then
If mName <> value Then
mName = value
"Property set not allowed")
The new Expert VB/C# 2005 Business Objects books and thus the CSLA .NET 2.0 framework are slated for public release in Mar/Apr 2006.
Powered by: newtelligence dasBlog 2.0.7226.0
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.
© Copyright 2013, Marimer LLC