Hi Rocky,
In one of your post related to CSLA performance for large collection you mentioned that:
"One thing I'll point out, is that in CSLA .NET 2.0 each object (row) loads its own validation rules, and that will add up to a lot of overhead with 1000+ rows. Version 2.1 will help address this with per-type validation and authorization rules. For your testing, I would suggest starting with no validation or authorization rules in the objects for now.
Is new version address per-type validation and authorization rules ? Right now I am using version 2.0 and want to make use of version 2.1.
Thanks,
Dileep Agarwal
Dileep
Making the change from 2.0 to 2.1 isn’t that hard as long as you appreciate the options Rocky has provided in the new version.
If you have validation rules in your classes in 2.0, these can easily rewritten using the generic AddRule method. The example below is an extract from one of my classes that represents a child in an institution. The validation rule shown, validates that the child’s name has been set. Note that the validationrule is static and is therefore a per-type rule.
Protected Overrides Sub AddBusinessRules()
MyBase.AddBusinessRules()
With ValidationRules
.AddRule(Of Child)(AddressOf ValidateName, "Name")
.AddDependantProperty("FirstName", "Name")
.AddDependantProperty("MiddleName", "Name")
.AddDependantProperty("LastName", "Name")
End With
End Sub
''' <summary>
''' Validates that either firstname, middlename or lastname has been set.
''' </summary>
Private Shared Function ValidateName(ByVal target As Child, ByVal e As RuleArgs) As Boolean
If target._requireName Then
Dim name As String
Name = String.Concat(target.FirstName & target.MiddleName & target.LastName).Trim
If name.Length <= 0 Then
e.Description = "Child name is required!"
Return False
End If
End If
Return True
End Function
Since the rule is added as a generic rule of Child and the target in the validation method is declared as type Child, you’ll be able to get to the fields of the instance being validated through this target.
Hope this can get you started.
Cheers
/Henrik
Copyright (c) Marimer LLC