CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
HasLambdaRules.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Csla.Rules;
6
8{
10 public class HasLambdaRules : BusinessBase<HasLambdaRules>
11 {
12 public static PropertyInfo<string> SsnProperty = RegisterProperty<string>(c => c.Ssn);
13
14 public string Ssn
15 {
16 get { return GetProperty(SsnProperty); }
17 set { SetProperty(SsnProperty, value); }
18 }
19
20 public static PropertyInfo<string> Ssn2Property = RegisterProperty<string>(c => c.Ssn2);
21
22 public string Ssn2
23 {
24 get { return GetProperty(Ssn2Property); }
25 set { SetProperty(Ssn2Property, value); }
26 }
27
29 {
30 return dataPortal.Create();
31 }
32
33 [RunLocal]
34 [Create]
35 protected void DataPortal_Create()
36 {
37 LoadProperty(SsnProperty, string.Empty);
38 LoadProperty(Ssn2Property, string.Empty);
40 }
41
42 public string[] GetRuleDescriptions()
44 }
45
46 protected override void AddBusinessRules()
47 {
48 BusinessRules.AddRule<HasLambdaRules>(SsnProperty, (o) => !string.IsNullOrEmpty(o.Ssn), "must have value 1");
49 BusinessRules.AddRule<HasLambdaRules>(SsnProperty, (o) => o.Ssn != null && o.Ssn.Length > 15, "cannot be longer than 15 chars");
50
51 BusinessRules.AddRule<HasLambdaRules>(SsnProperty, (o) => !string.IsNullOrEmpty(o.Ssn2), () => "must have value 1");
52 BusinessRules.AddRule<HasLambdaRules>(SsnProperty, (o) => !string.IsNullOrEmpty(o.Ssn2), () => "must have value 2");
53 }
54 }
55}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
Tracks the business rules for a business object.
List< string > CheckRules()
Invokes all rules for the business type.
void AddRule(IBusinessRuleBase rule)
Associates a business rule with the business object.
string[] GetRuleDescriptions()
Gets a list of rule:// URI values for the rules defined in the object.
static PropertyInfo< string > SsnProperty
static HasLambdaRules New(IDataPortal< HasLambdaRules > dataPortal)
static PropertyInfo< string > Ssn2Property
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17
object Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Create
Create operation.