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.
SimpleRoot.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="SimpleRoot.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>The unique ID of this object</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11
13{
14 [Serializable()]
15 class SimpleRoot : BusinessBase<SimpleRoot>
16 {
17 private string _Data = string.Empty;
22 protected override object GetIdValue()
23 {
24 return this._Data;
25 }
29 public string Data
30 {
31 get { return this._Data; }
32 set
33 {
34 if (!this._Data.Equals(value))
35 {
36 this._Data = value;
37 this.MarkDirty();
38 }
39 }
40 }
44 [Serializable()]
45 internal class Criteria
46 {
47 public const string DefaultData = "<new>";
48
49 private string _Data = string.Empty;
50 public string Data
51 {
52 get { return this._Data; }
53 set { this._Data = value; }
54 }
55 public Criteria()
56 {
57 this._Data = Criteria.DefaultData;
58 }
59 public Criteria(string Data)
60 {
61 this._Data = Data;
62 }
63 }
64
69 private void DataPortal_Create(object criteria)
70 {
71 Criteria crit = criteria as Criteria;
72 this._Data = crit.Data;
73
74 TestResults.Add("Root", "Created");
75 }
80 protected void DataPortal_Fetch(object criteria)
81 {
82 Criteria crit = criteria as Criteria;
83 this._Data = crit.Data;
84
85 this.MarkOld();
86 TestResults.Add("Root", "Fetched");
87 }
91 [Update]
92 protected void DataPortal_Update()
93 {
94 if (this.IsDeleted)
95 {
96 TestResults.Add("Root", "Deleted");
97 this.MarkNew();
98 }
99 else
100 {
101 if (this.IsNew)
102 {
103 TestResults.Add("Root", "Inserted");
104 }
105 else TestResults.Add("Root", "Updated");
106
107 this.MarkOld();
108 }
109 }
114 [Delete]
115 protected void DataPortal_Delete(object criteria)
116 {
117 TestResults.Add("Root", "Deleted");
118 }
119 }
120}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
override object GetIdValue()
The unique ID of this object
Definition: SimpleRoot.cs:22
string Data
The data value for this object
Definition: SimpleRoot.cs:30
void DataPortal_Fetch(object criteria)
Handles DataPortal fetch calls
Definition: SimpleRoot.cs:80
void DataPortal_Delete(object criteria)
Definition: SimpleRoot.cs:115
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
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
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Delete
Delete operation.