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.
Csla.test/BasicModern/Root.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.ComponentModel.DataAnnotations;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7using Csla;
9
11{
13 public class Root : BusinessBase<Root>
14 {
15 public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(nameof(Id));
16 public int Id
17 {
18 get { return GetProperty(IdProperty); }
19 set { SetProperty(IdProperty, value); }
20 }
21
22 public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name));
23 [Required]
24 public string Name
25 {
26 get { return GetProperty(NameProperty); }
27 set { SetProperty(NameProperty, value); }
28 }
29
30 public static readonly PropertyInfo<ChildList> ChildrenProperty = RegisterProperty<ChildList>(nameof(Children));
31 public ChildList Children
32 {
33 get { return GetProperty(ChildrenProperty); }
34 private set { LoadProperty(ChildrenProperty, value); }
35 }
36
37 public void MakeOld()
38 {
39 MarkOld();
40 }
41
42 [Create]
43 protected void DataPortal_Create([Inject] IChildDataPortal<ChildList> childDataPortal)
44 {
45 Children = childDataPortal.CreateChild();
46 BusinessRules.CheckRules();
47 }
48
49 private void DataPortal_Fetch(int id, [Inject] IChildDataPortal<ChildList> childDataPortal)
50 {
51 Children = childDataPortal.CreateChild();
52 }
53
54 [Insert]
55 protected void DataPortal_Insert()
56 {
57 FieldManager.UpdateChildren();
58 }
59
60 [Update]
61 protected void DataPortal_Update()
62 {
63 FieldManager.UpdateChildren();
64 }
65
66 [DeleteSelf]
67 protected void DataPortal_DeleteSelf()
68 {
69 DataPortal_Delete(ReadProperty(IdProperty));
70 }
71
72 [Delete]
73 private void DataPortal_Delete(int id)
74 {
75 FieldManager.UpdateChildren();
76 }
77 }
78}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
static readonly PropertyInfo< string > NameProperty
static readonly PropertyInfo< ChildList > ChildrenProperty
void DataPortal_Create([Inject] IChildDataPortal< ChildList > childDataPortal)
static readonly PropertyInfo< int > IdProperty
Interface defining the members of the child data portal type.
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Create
Create operation.
@ Delete
Delete operation.