CSLA .NET 3.6 and higher normally requires .NET 3.5 SP1. However, if you are using Visual Studio 2008 it is possible (with some work and a third party LINQ library) to get the current functionality of CSLA .NET running on .NET 2.0 SP1. Jonny Bekkum has done just that, and has contributed the results of his efforts to the community - thank you Jonny!
This is a large subset of the current version CSLA .NET for Windows that builds and runs on .NET 2.0 SP1.
Standard versions of CSLA .NET are available from the download page.
You can download CSLA .NET N2 here:
From Jonny:
Why create a version 3.6/3.7 of CSLA .NET for .NET 2.0?
The latest version of CSLA .NET N2 used to be version 3.0.5 and the Expert C# 2005 Business Objects book. Since this version was released there has been a lot of development going into the 3.5, 3.6 and 3.7 versions and the newest book: Expert C# 2008 Business Objects.
With the introduction of CSLA .NET N2 you should also read the 2008 book and just skip the chapters 14, 19 and 21. Any references to Linq2Sql, Linq2EntityFramework, WCF, WPF, WF and Silverlight are not valid for this version but all other features are applicable.
This version of CSLA .NET N2 is primarily targeting Windows Forms developers that still must support .NET 2.0 applications.
Visual Studio 2008 and multitargeting
When we moved to Visual Studio 2008 and started having a mix of CSLA .NET 3.0.5 and 3.5 projects (targeting .NET 2.0 and .NET 3.5) it got very confusing having different sets of property snippets and coding syntax.
With the discovery of LinqBridge and creating the CSLA .NET N2 we could use the same coding syntax in Visual Studio 2008. And using the new C# 3.0 syntax (including Linq2Objects) makes you write less code and be more efficient.
Another benefit is the easier upgrade path to CSLA .NET 3.7 and WPF/Silverlight clients as the code should compile with just replacing with the newest version of CSLA .NET, updated references and change the target framework.
What is LinqBridge?
LINQBridge is a reimplementation of all the standard query operators in .NET 3.5's Enumerable class. It's designed to work with the C# 3.0 compiler, as used by Visual Studio 2008. LINQBridge comprises a "LINQ to Objects" API for running local queries.
LINQBridge also includes .NET 3.5's generic Func and Action delegates, as well as ExtensionAttribute, allowing you to use C# 3.0's extension methods in .NET 2.0.
In fact LINQBridge lets you use nearly all of the features in C# 3.0 with .NET 2.0—including extension methods, lambda functions and query comprehensions. The only feature it does not support is compiling lambdas to expression trees (i.e., Expression<TDelegate>).
Read more about LinqBridge here: http://www.albahari.com/nutshell/linqbridge.aspx
What do we get from CSLA .NET 3.6+ compared to CSLA .NET 3.0.5?
You get to use the most of new development in CSLA .NET like :
- Managed properties in BusinessBase, ReadOnlyBase and CommandBase that reduces the number of lines required to declare a property.
- PropertyInfo type for less hardcoding of propertynames in your code.
- FieldManager and DataPortal enhancements, including the asynchronous DataPortal and Child_XYZ mehthods.
- ObjectFactory for separation of BO and DAL
- CslaActionExtender reduces the amount of code behind required in Windows Forms
- Reflection enhancements (MethodCaller) for dynamic calls
- An easier upgrade path to CSLA .NET 3.7 and Silverlight
- and a lot more ….
Download the samples and look at the ProjectTrackercs, MethodCallerSample and ActionExtenderSample. They all show you different new features .
The new C# 3.0 Syntax
If you are still using Visual Studio 2005 – move on to Visual Studio 2008 ASAP. I love the new C# 3.0 syntax and with CSLA .NET N2 you will also write less code.
Just to list a few of the new C# 3.0 syntax you get:
- Lambda expressions
- Extension methods
- Implicitly typed local variables (the var keyword)
- Query comprehensions
- Anonymous types
- Object initializers
- Implicitly typed arrays
- Automatic properties
- Partial methods
What to expect when upgrading from earlier versions of CSLA .NET.
You should expect the same issues as when upgrading to use CSLA .NET for Windows 3.5 or higher.
CSLA .NET 3.5 and higher are more strict interms of databinding and will often reveal problems/errors in databinding. These problems will usually result in a "EditLevel mistmatch" error when trying to Save or Delete your object graph.
You should carefully review the "Change log" starting from your current version of CSLA .NET for Windows up to the current version.
The MobileFormatter must use XmlSerializer in .NET 2.0 and this may cause you problems as the XmlSerializer is not able to serialize generic classes. This sould normally not represent aproblem as you should not use the MobileFormatter in a Windows/ASP.NET application.
What do you get by upgrading to CSLA .NET N2
You will be able to use a load of new features in your code (and actually may compile the same code with latest version of CSLA .NET for Silverlight/WPF projects).
Some of the new features are:
- BusinessBase, ReadOnlyBase, CriteriaBase and CommandBase enhancements
- RegisterProperty declarations
- also decreases hardcoded propertynames in your code.
- GetProperty/SetProperty
- ReadProperty/LoadProperty
- new SingleCriteria<T>
- DataPortal enhancement
- ObjectFactory
- async DataPortal<T>
- ChildDataPortal
- MethodCaller that generates IL code thru Reflection.Emit
- CSLA .NETActionExtender
- BindingSourceHelper
Just to list some of the most valuable enhancements.
And support for nearly all the new C# 3.0 syntax (by LinqBridge.dll)
Read more about this here: http://www.albahari.com/nutshell/linqbridge.aspx
New class templates and snippets are also included.
All settings/configuration is the same as CSLA .NET for Windows except for
- CSLA .NETSerializationFormatter is not honored. SerializationFormatterFactory.GetFormatter() will always return the Binaryformatter.
The Expert C# 2008 Business Objects book is highly recommended reading.
What to expect when moving a project from .NET 3.5 to CSLA .NET N2.
Obviously you will not be able to use the .NET 3.5 or .NET 3.0 assemblies and so none of the following technologies are available:
- Wcf(and the NetDataContractSerializer)
- Wpf
- WF
- Silverlight
- Linq2EF and Linq2Sql helper classes
- Expressions and Linq integration (including LinqBindingList and indexing in lists)
You will find the following methods/classes to be missing:
- RegisterProperty<string>(p=>p.Name);
is not available because this function takes an Expression as parameter. rewrite code to use other overloads that take PropertyName as parameter.
is not available bacuse it requires Indexset and Expression that are 3.5 technology. Reqrite code to use SortedBindingList and FilteredBindingList.
- Linq enhancements (indexing and LinqBindingList) are not available. The IndexableAttribute is included and valid but will not result in enhanced responses/indexing in this version of CSLA .NET.
CSLA .NET for Windows is not compatible to CSLA .NET N2 using the BinaryFormatter so if you if you are using remote Dataportal (mobile objects) you must use the same CSLA .NET version on both computers.