Skip to content

Commit

Permalink
HTMLDoc Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ljlclark committed Feb 11, 2024
1 parent 56e0bbb commit 0f333fe
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 13 deletions.
13 changes: 0 additions & 13 deletions HTML/HTMLDocs/DataAccess/DALTestAdd.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,6 @@ <h4 class="headingMargin">Database Assigned Values</h4>
Console.WriteLine();
Console.WriteLine("TestAdd");

// Delete existing "Added" record to allow for new Add.
Person keyRecord = new Person()
{
Name = "Added"
};
personManager.SetExcludeKeys();
Person lookupRecord = personManager.Retrieve(keyRecord);
if (lookupRecord != null)
{
personManager.SetExcludeKeys();
personManager.Delete(keyRecord);
}

// Add record
Person dataRecord = new Person()
{
Expand Down
141 changes: 141 additions & 0 deletions HTML/HTMLDocs/DataAccess/DALTestAddSave.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<!DOCTYPE html>
<!-- Copyright (c) Lester J. Clark and Contributors. -->
<!-- Licensed under the MIT License. -->
<!-- DALTestAdd.html -->
<html>
<head>
<title>Data Test Add</title>
<link rel="stylesheet" type="text/css" href="../CSS/CodeDoc.css" />
<link rel="stylesheet" type="text/css" href="../CSS/HTMLBooks.css" />
<link rel='stylesheet' type='text/css' href='../CSS/Syntax.css' />
</head>
<body>
<div class="page">
<a href="DALTestLoad.html">The DAL Test Add() Method</a>
<br />
<h3 class="headingMargin">The Add() Method</h3>
<!-- ******************************* -->
<div class="columns">
<p class="book">
The inherited PersonManager.Add() method adds a new record to the
configured table.
</p>
<h4 class="headingMargin">Database Assigned Values</h4>
<p class="book">
The Add() method has some unique functionality to handle database assigned
values. These are values that are assigned by the database when a column
is defined as AutoIncrement or by a database trigger.
</p>
<ul class="listMargin">
<li>
Add the &quot;GetKey Methods&quot; region to the PersonManager class.
</li>
<li>
Add the SetExcludeKeys() method to the PersonManager class, &quot;GetKey
Methods&quot; region.
</li>
</ul>
</div>
<pre class="code">
#region GetKey Methods

// Sets the temporary exclude keys.
/// <include path='items/SetExcludeKeys/*' file='../../CommonManager.xml' />
public void SetExcludeKeys()
{
string[] excludeNames = new string[]
{
Person.ColumnPrincipleFlag
};
SetExcludeKeyValues(excludeNames);
}
#endregion</pre>
<!-- ******************************* -->
<div class="columnsAuto">
<ul class="listMargin">
<li>
Add the TestAdd() function to the Program class, &quot;TestFunctions&quot; region.
</li>
</ul>
</div>
<pre class="code">
// Test the Add function.
private static void TestAdd(PersonManager personManager)
{
Console.WriteLine();
Console.WriteLine("TestAdd");

// Delete existing "Added" record to allow for new Add.
Person keyRecord = new Person()
{
Name = "Added"
};
personManager.SetExcludeKeys();
Person lookupRecord = personManager.Retrieve(keyRecord);
if (lookupRecord != null)
{
personManager.SetExcludeKeys();
personManager.Delete(keyRecord);
}

// Add record
Person dataRecord = new Person()
{
Name = "Added",
PrincipleFlag = false
};
Person addedRecord = personManager.Add(dataRecord);
if (addedRecord != null)
{
dataRecord.ID = addedRecord.ID;
WriteRowString(dataRecord);
}
}</pre>
<!-- ******************************* -->
<div class="columns">
<ul class="listMargin">
<li>
Add the TestAdd(personManager) function call to the Program class, &quot;Test function calls.&quot; section.
</li>
</ul>
</div>
<h4 class="headingMargin">The Key Record Object</h4>
<!-- ******************************* -->
<div class="columns">
<p class="book">
The key record data object is used to modify a data method to restrict it
to those records that match the key record initialized properties.
</p>
<p class="book">
There are some properties that are automatically initialized in a data
object. These are properties such as numeric and DateTime. Numeric
properties are automatically initialized to zero.
</p>
<p class="book">
If we create a Person key record and set the Name property, the
PrincipleFlag property is automatically initialized to zero. This causes
the personManager.Retrieve(keyRecord) method to internally create the
following SQL statement.
</p>
</div>
<pre class="code">
select ID, Name, PrincipleFlag
from Person
where Name = &apos;Added&apos; and PrincipleFlag = &apos;0&apos;.</pre>
<div class="columns">
<p class="book">
To prevent the PrincipleFlag value from being included in the SQL
statement, we first call the SetExcludeKeys() method.
</p>
<p class="book">
The SetExcludeKeys() manager method is used to temporarily exclude
specific fields from the SQL statement created from the KeyRecord object.
The manager exclude keys are cleared after a call to any data access
method.
</p>
</div>
<br />
<a href="DALTestRetrieve.html">The DAL Test Retrieve() Method</a>
</div>
</body>
</html>

0 comments on commit 0f333fe

Please sign in to comment.