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.
Silverlight/Server/DataPortal/PrimitiveCriteriaSingle.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="PrimitiveCriteriaSingle.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.Collections.Generic;
9using System.Text;
10
11using Csla;
12using System;
13using Csla.Core;
14
16{
17#if TESTING
18 [System.Diagnostics.DebuggerNonUserCode]
19#endif
21 public class PrimitiveCriteriaSingle : BusinessBase<PrimitiveCriteriaSingle>
22 {
23 #region Business Methods
24
25 public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
26 public int Id
27 {
28 get { return GetProperty(IdProperty); }
29 set { SetProperty(IdProperty, value); }
30 }
31
32 private static PropertyInfo<string> MethodCalledProperty = RegisterProperty<string>(c => c.MethodCalled);
33 public string MethodCalled
34 {
35 get { return GetProperty(MethodCalledProperty); }
36 set { SetProperty(MethodCalledProperty, value); }
37 }
38
39 protected override object GetIdValue()
40 {
41 return Id;
42 }
43
44 #endregion
45
47 { }
48
49 #region Data Access
50
51 #region DataPortal_Create
52
53 protected void DataPortal_Create(int id)
54 {
55 DoCreate(id);
56 }
57
58 private void DoCreate(int id)
59 {
60 Id = id;
61#pragma warning disable CS0618 // Type or member is obsolete
62 ApplicationContext.GlobalContext.Clear();
63 ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", "Created");
64#pragma warning restore CS0618 // Type or member is obsolete
65 MethodCalled = "Created";
66 if (id == 9999)
67 throw new Exception("Bad data");
68 }
69
70 #endregion
71
72 #region DataPortal_Fetch
73
74
75 private void DataPortal_Fetch(int id)
76 {
77 DoFetch(id);
78 }
79
80 private void DataPortal_Fetch(string id)
81 {
82 DoFetch(int.Parse(id));
83 }
84
85 private void DataPortal_Fetch(Guid id)
86 {
87 DoFetch(1234);
88 }
89
90 private void DoFetch(int id)
91 {
92 Id = id;
93#pragma warning disable CS0618 // Type or member is obsolete
94 ApplicationContext.GlobalContext.Clear();
95 ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", "Fetched");
96#pragma warning restore CS0618 // Type or member is obsolete
97 MethodCalled = "Fetched";
98 if (id == 9999)
99 throw new Exception("Bad data");
100 }
101
102 #endregion
103
104 #region DataPortal_Insert / DataPortal_Update / DataPortal_Delete
105
106 [Insert]
107 protected void DataPortal_Insert()
108 {
109 DoInsertUpdate(false);
110 }
111
112 private void DoInsertUpdate(bool isUpdate)
113 {
114 var insertOrUpdate = isUpdate ? "Updated" : "Inserted";
115
116#pragma warning disable CS0618 // Type or member is obsolete
117 ApplicationContext.GlobalContext.Clear();
118 ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", insertOrUpdate);
119#pragma warning restore CS0618 // Type or member is obsolete
120 MethodCalled = insertOrUpdate;
121 }
122
123
124
125 #endregion
126
127
128 [Delete]
129 private void DataPortal_Delete(int id)
130 {
131#pragma warning disable CS0618 // Type or member is obsolete
132 ApplicationContext.GlobalContext.Clear();
133 ApplicationContext.GlobalContext.Add("PrimitiveCriteriaSingle", "Deleted");
134#pragma warning restore CS0618 // Type or member is obsolete
135 MethodCalled = "Deleted+" + id.ToString();
136 }
137
138 #endregion
139 }
140}
Provides consistent context information between the client and server DataPortal objects.
void Clear()
Clears all context collections.
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
override object GetIdValue()
Override this method to return a unique identifying value for this object.
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Delete
Delete operation.