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/Basic/GenRootBase.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="GenRootBase.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11
12namespace Csla.Test.Basic
13{
14 [Serializable()]
15 public abstract class GenRootBase : BusinessBase<GenRoot>
16 {
17 private string _data = "";
18
19 protected override object GetIdValue()
20 {
21 return _data;
22 }
23
24 public string Data
25 {
26 get { return _data; }
27 set
28 {
29 if (_data != value)
30 {
31 _data = value;
32 MarkDirty();
33 }
34 }
35 }
36
37 [Serializable()]
38 public class Criteria : CriteriaBase<Criteria>
39 {
40 public string _data;
41
42 public Criteria()
43 {
44 _data = "<new>";
45 }
46
47 public Criteria(string data)
48 {
49 this._data = data;
50 }
51 }
52
53 [Create]
54 private void DataPortal_Create(object criteria)
55 {
56 Criteria crit = (Criteria)(criteria);
57 _data = crit._data;
58 TestResults.Add("GenRoot", "Created");
59 }
60
61 [Fetch]
62 protected void DataPortal_Fetch(object criteria)
63 {
64 Criteria crit = (Criteria)(criteria);
65 _data = crit._data;
66 MarkOld();
67 TestResults.Add("GenRoot", "Fetched");
68 }
69
70 [Update]
71 protected void DataPortal_Update()
72 {
73 if (IsDeleted)
74 {
75 //we would delete here
76 TestResults.Add("GenRoot", "Deleted");
77 MarkNew();
78 }
79 else
80 {
81 if (IsNew)
82 {
83 //we would insert here
84 TestResults.Add("GenRoot", "Inserted");
85 }
86 else
87 {
88 //we would update here
89 TestResults.Add("GenRoot", "Updated");
90 }
91 MarkOld();
92 }
93 }
94
95 [Delete]
96 protected void DataPortal_Delete(object Criteria)
97 {
98 //we would delete here
99 TestResults.Add("GenRoot", "Deleted");
100 }
101 }
102}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Base type from which Criteria classes can be derived in a business class.
Definition: CriteriaBase.cs:25
override object GetIdValue()
Override this method to return a unique identifying value for this object.
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).
@ Fetch
Fetch operation.
@ Create
Create operation.
@ Delete
Delete operation.