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.
ExceptionRoot.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ExceptionRoot.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6//-----------------------------------------------------------------------
7using System;
8using System.Collections.Generic;
9using System.Text;
10
12{
13 [Serializable()]
14 class ExceptionRoot : BusinessBase<ExceptionRoot>
15 {
16 private string _Data = string.Empty;
17 public string Data
18 {
19 [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
20 get { return this._Data; }
21 [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
22 set { this._Data = value; }
23 }
24
25 protected override object GetIdValue()
26 {
27 return this._Data;
28 }
29
30 [Serializable()]
31 internal class Criteria
32 {
33 public const string DefaultData = "<new>";
34
35 private string _Data;
36
37 public string Data
38 {
39 [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
40 get { return this._Data; }
41 }
42
43 public Criteria()
44 {
45 this._Data = Criteria.DefaultData;
46 }
47
48 public Criteria(string Data)
49 {
50 this._Data = Data;
51 }
52 }
53
54 protected void DataPortal_Fetch(object criteria)
55 {
56 Criteria crit = criteria as Criteria;
57 this._Data = crit.Data;
58 this.MarkOld();
59
60 TestResults.Add("Root", "Fetched");
61 TestResults.Add("create", "create");
62 throw new ApplicationException("Fail fetch");
63 }
64
65 private void DataPortal_Create(object criteria)
66 {
67 Criteria crit = criteria as Criteria;
68 this._Data = crit.Data;
69
70 TestResults.Add("Root", "Created");
71 TestResults.Add("create", "create");
72 throw new ApplicationException("Fail create");
73 }
74
75 [Insert]
76 protected void DataPortal_Insert()
77 {
78 //we would insert here
79 TestResults.AddOrOverwrite("Root", "Inserted");
80 TestResults.AddOrOverwrite("create", "create");
81 throw new ApplicationException("Fail insert");
82 }
83
84 [Update]
85 protected void DataPortal_Update()
86 {
87 TestResults.AddOrOverwrite("Root", "Updated");
88 TestResults.AddOrOverwrite("create", "create");
89 throw new ApplicationException("Fail update");
90 }
91
92 [Delete]
93 protected void DataPortal_Delete(object criteria)
94 {
95 TestResults.AddOrOverwrite("Root", "Deleted");
96 TestResults.AddOrOverwrite("create", "create");
97 throw new ApplicationException("Fail delete");
98 }
99
100 [DeleteSelf]
101 protected void DataPortal_DeleteSelf()
102 {
103 TestResults.Add("Root", "Deleted");
104 TestResults.Add("create", "create");
105 throw new ApplicationException("Fail delete self");
106 }
107 }
108}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
void DataPortal_Delete(object criteria)
override object GetIdValue()
Override this method to return a unique identifying value for this object.
void DataPortal_Fetch(object criteria)
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
static void AddOrOverwrite(string key, string value)
Overwrite an item in the test results, to indicate an outcome of a particular operation
Definition: TestResults.cs:39
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.