9using System.Collections.Generic;
12using System.Data.SqlClient;
13using System.Configuration;
20 #region "Business methods"
29 private set { LoadProperty(
IDProperty, value); }
62 #region "Factory Methods"
66 return dataPortal.
Create();
71 return dataPortal.
Fetch(
new Criteria(
ID));
84 private class Criteria
88 public Criteria(
int id)
104 BusinessRules.CheckRules();
105 Console.WriteLine(
"DataPortal_Create");
110 Criteria crit = (Criteria)(criteria);
114 throw new System.ApplicationException(
"DataPortal_Fetch: you chose an unlucky number");
117 Console.WriteLine(
"DataPortal_Fetch");
120 BusinessRules.CheckRules();
135 SqlCommand cm1 =
new SqlCommand();
137 cm1.CommandText =
"INSERT INTO Table2(FirstName, LastName, SmallColumn) VALUES('Bill', 'Thompson', 'abc')";
142 SqlCommand cm2 =
new SqlCommand();
145 cm2.CommandText =
"INSERT INTO Table2(FirstName, LastName, SmallColumn) VALUES('";
146 cm2.CommandText += firstName;
147 cm2.CommandText +=
"', '" + lastName +
"', '" + smallColumn +
"')";
150 cm1.ExecuteNonQuery();
151 cm2.ExecuteNonQuery();
156 Console.WriteLine(
"DataPortal_Insert");
163 Console.WriteLine(
"DataPortal_Update");
171 Console.WriteLine(
"DataPortal_DeleteSelf");
179 Criteria crit = (Criteria)(criteria);
182 throw new System.ApplicationException(
"DataPortal_Delete: you chose an unlucky number");
185 Console.WriteLine(
"DataPortal_Delete");
192 #region "DataPortalException"
198 Console.WriteLine(
"OnDataPortalException called");
This is the base class from which most business objects will be derived.
Provides information about the DataPortal call.
Maintains metadata about a property.
static PropertyInfo< int > IDProperty
void DataPortal_DeleteSelf()
static PropertyInfo< string > SmallColumnProperty
static TransactionalRoot NewTransactionalRoot(IDataPortal< TransactionalRoot > dataPortal)
void DataPortal_Fetch(object criteria)
static PropertyInfo< string > LastNameProperty
static PropertyInfo< string > FirstNameProperty
static void DeleteTransactionalRoot(int ID, IDataPortal< TransactionalRoot > dataPortal)
static TransactionalRoot GetTransactionalRoot(int ID, IDataPortal< TransactionalRoot > dataPortal)
void DataPortal_Delete(object criteria)
override void AddBusinessRules()
override void DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex)
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
static void Reinitialise()
Reinitialise the dictionary, clearing any existing results, ready for the next test
static void Add(string key, string value)
Add an item to the test results, to indicate an outcome of a particular operation
static string DataPortalTestDatabase
Interface defining the members of the data portal type.
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...
TransactionalTypes
Provides a list of possible transactional technologies to be used by the server-side DataPortal.
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Create
Create operation.
@ Delete
Delete operation.