/ Home / HowTo / AddRecord

How to Configure DataAccess with ConnectionBuilder.
How to Configure DataAccess with DataConfigs.

using LJCDBClientLib;
using LJCDBMessage;
using System.Collections.Generic;
using System.Data;

// Add a data record.
internal Province Add(Province province, string connectionString
  , string providerName)
{
  Province retValue;

  // Create the SQLManager.
  var sqlManager = new SQLManager(null, "Province", connectionString
    , providerName);

  // Create the list of DB Assigned and Lookup column names.
  sqlManager.DbAssignedColumns = new List()
  {
    "ID"
  };
  sqlManager.SetLookupColumns(new string[]
  {
    "Name"
  });

  // The data record must not contain a value for DB Assigned columns.
  var propertyNames = new List()
  {
    { "Name" },
    { "Description" },
    { "Abbreviation" }
  };
  DataTable dbAssignedValues = sqlManager.Add(province, propertyNames);

  // Create the Data Object with added DB Assigned values.
  // Sets object values where DataTable column names match
  // the object property names and DataTable column row
  // values are not null.
  // If DataRow is not provided, first row is used if available.
  var converter = new ResultConverter<Province, Provinces>();
  retValue = converter.CreateDataFromTable(dbAssignedValues);
  return retValue;
}
/ Home / HowTo / AddRecord

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