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.netcore.test/DataBinding/ParentEntity.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ParentEntity.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>DO NOT USE in UI - use the factory method instead</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using System.Data;
12using System.Data.SqlClient;
13
15{
16 [Serializable()]
17 public class ParentEntity : BusinessBase<ParentEntity>
18 {
19 #region "Business methods"
20
21 private ChildEntityList _children;
22 [NotUndoable()]
23 private string _notUndoable;
24
25 public string NotUndoable
26 {
27 get { return _notUndoable; }
28 set { _notUndoable = value; }
29 }
30
31 public static PropertyInfo<int> IDProperty = RegisterProperty<int>(c => c.ID);
32 public int ID
33 {
34 get { return GetProperty(IDProperty); }
35 private set { LoadProperty(IDProperty, value); }
36 }
37
38 public static PropertyInfo<string> DataProperty = RegisterProperty<string>(c => c.Data);
39 public string Data
40 {
41 get { return GetProperty(DataProperty); }
42 set { SetProperty(DataProperty, value); }
43 }
44
46 {
47 get { return _children; }
48 }
49
50 public override bool IsDirty
51 {
52 get
53 {
54 return base.IsDirty || _children.IsDirty;
55 }
56 }
57
58 #endregion
59
60 protected override void AddBusinessRules()
61 {
62 //don't need rules for databinding tests
63 //ValidationRules.AddRule(Validation.CommonRules.StringRequired, "Data");
64 }
65
66 #region "constructors"
67
74 public ParentEntity()
75 {
76 //if we need authorization rules:
77 //this.AuthorizationRules.AllowWrite("Data", "Admin");
78 //this.AuthorizationRules.AllowRead("Data", "Admin");
79 }
80
81 #endregion
82
83 #region "Criteria"
84
85 [Serializable()]
86 private class Criteria
87 {
88 public int _id;
89
90 public Criteria(int id)
91 {
92 this._id = id;
93 }
94 }
95
96 #endregion
97
98 #region "Data Access"
99
100 [RunLocal()]
101 [Create]
102 protected void DataPortal_Create([Inject] IChildDataPortal<ChildEntityList> dataPortal)
103 {
105 TestResults.Add("ParentEntity", "Created");
106 _children = dataPortal.CreateChild();
107 BusinessRules.CheckRules();
108 Console.WriteLine("DataPortal_Create");
109 }
110
111 [Fetch]
112 protected void DataPortal_Fetch(object criteria, [Inject] IChildDataPortal<ChildEntityList> dataPortal)
113 {
114 _children = dataPortal.CreateChild();
115 Console.WriteLine("DataPortal_Fetch");
117 TestResults.Add("ParentEntity", "Fetched");
118 BusinessRules.CheckRules();
119 }
120
121 [Insert]
122 protected void DataPortal_Insert()
123 {
125 TestResults.Add("ParentEntity", "Inserted");
126 Console.WriteLine("DataPortal_Insert");
127 }
128
129 [Update]
130 protected void DataPortal_Update()
131 {
132 Console.WriteLine("DataPortal_Update");
134 TestResults.Add("ParentEntity", "Updated");
135 }
136
137 [DeleteSelf]
138 protected void DataPortal_DeleteSelf()
139 {
140 Console.WriteLine("DataPortal_DeleteSelf");
142 TestResults.Add("ParentEntity", "Deleted Self");
143 }
144
145 [Delete]
146 protected void DataPortal_Delete(object criteria)
147 {
148 Console.WriteLine("DataPortal_Delete");
150 TestResults.Add("ParentEntity", "Deleted");
151 }
152
153 #endregion
154 }
155}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
bool IsDirty
Gets a value indicating whether this object's data has been changed.
Maintains metadata about a property.
void DataPortal_Fetch(object criteria, [Inject] IChildDataPortal< ChildEntityList > dataPortal)
ParentEntity()
DO NOT USE in UI - use the factory method instead
void DataPortal_Create([Inject] IChildDataPortal< ChildEntityList > dataPortal)
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
static void Reinitialise()
Reinitialise the dictionary, clearing any existing results, ready for the next test
Definition: TestResults.cs:69
static void Add(string key, string value)
Add an item to the test results, to indicate an outcome of a particular operation
Definition: TestResults.cs:29
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).
@ Fetch
Fetch operation.
@ Create
Create operation.
@ Delete
Delete operation.