/ Home / HowTo / DAL

The DAL Test Add() Method

The Add() Method

The inherited PersonManager.Add() method adds a new record to the configured table.

Database Assigned Values

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.

  // Create the list of database assigned columns.
  // And make sure the AutoIncrement value is set.
  DbAssignedColumnNames = new string[]
  {
    Person.ColumnID
  };

  // Create the list of lookup column names.
  // This list must include the database assigned columns
  // to contain the returned DB assigned values.
  LookupColumnNames = new string[]
  {
    Person.ColumnID,
    Person.ColumnName
  }
// Test the Add function.
private static void TestAdd(PersonManager personManager)
{
  Console.WriteLine();
  Console.WriteLine("TestAdd");

  // Add record
  Person dataRecord = new Person()
  {
    Name = "Added",
    PrincipleFlag = false
  };
  Person addedRecord = personManager.Add(dataRecord);
  if (addedRecord != null)
  {
    dataRecord.ID = addedRecord.ID;
    WriteRowString(dataRecord);
  }
}
if (success)
{
    // Test function calls.
  TestLoad(personManager);
  TestAdd(personManager);

  Console.WriteLine("Press any key to continue . . .");
  Console.ReadKey();
}

The DAL Test Retrieve() Method
/ Home / HowTo / DAL

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.