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.
NullableObject.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="NullableObject.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
13{
14 [Serializable()]
15 public class NullableObject : BusinessBase<NullableObject>
16 {
17 private string _name = string.Empty;
18 private Nullable<int> _nullableInteger;
19 public Nullable<int> _nullableIntMember;
20
21 protected override object GetIdValue()
22 {
23 return _name;
24 }
25
26 public string Name
27 {
28 get { return _name; }
29 set
30 {
31 _name = value;
32 }
33 }
34
35 public Nullable<int> NullableInteger
36 {
37 get { return _nullableInteger; }
38 set
39 {
40 if (this._nullableInteger != value)
41 {
42 this._nullableInteger = value;
43 MarkDirty();
44 }
45 }
46 }
47
48 [Serializable()]
49 private class Criteria
50 {
51 public string _name;
52
53 public Criteria()
54 {
55 _name = "<new>";
56 }
57
58 public Criteria(string name)
59 {
60 this._name = name;
61 }
62 }
63
65 {
66 return dataPortal.Create(new Criteria()) as NullableObject;
67 }
68
69 public static NullableObject GetNullableObject(string name, IDataPortal<NullableObject> dataPortal)
70 {
71 return dataPortal.Fetch(new Criteria(name)) as NullableObject;
72 }
73
74 public static void DeleteNullableObject(string name, IDataPortal<NullableObject> dataPortal)
75 {
76 dataPortal.Delete(new Criteria(name));
77 }
78
80 {
81 AddBusinessRules();
82 }
83
84 private void DataPortal_Create(object criteria)
85 {
86 Criteria crit = (Criteria)(criteria);
87 _name = crit._name;
88 //Name = crit._name;
89 TestResults.Add("NullableObject", "Created");
90 }
91
92 protected void DataPortal_Fetch(object criteria)
93 {
94 Criteria crit = (Criteria)(criteria);
95 _name = crit._name;
96 MarkOld();
97 TestResults.Add("NullableObject", "Fetched");
98 }
99
100 [Update]
101 protected void DataPortal_Update()
102 {
103 if (IsDeleted)
104 {
105 //we would delete here
106 TestResults.Add("NullableObject", "Deleted");
107 MarkNew();
108 }
109 else
110 {
111 if (this.IsNew)
112 {
113 //we would insert here
114 TestResults.Add("NullableObject", "Inserted");
115 }
116 else
117 {
118 //we would update here
119 TestResults.Add("NullableObject", "Updated");
120 }
121 MarkOld();
122 }
123 }
124
125 [Delete]
126 protected void DataPortal_Delete(object criteria)
127 {
128 //we would delete here
129 TestResults.Add("NullableObject", "Deleted");
130 }
131
132
133 }
134}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
void DataPortal_Delete(object criteria)
static NullableObject GetNullableObject(string name, IDataPortal< NullableObject > dataPortal)
override object GetIdValue()
Override this method to return a unique identifying value for this object.
void DataPortal_Fetch(object criteria)
static void DeleteNullableObject(string name, IDataPortal< NullableObject > dataPortal)
static NullableObject NewNullableObject(IDataPortal< NullableObject > dataPortal)
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
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17
void Delete(params object[] criteria)
Called by a Shared (static in C#) method in the business class to cause immediate deletion of a speci...
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
object Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Delete
Delete operation.