This is sample supporting code for a Person Manager class. The additional code for the suggested Person manager methods Add(), Retrieve(), Load(), Update() and Delete() is listed under the DataManager methods with the same names.
using System; using System.Collections.Generic; using LJCNetCommon; using LJCDBClientLib; using LJCDBServiceLib; /// <summary> /// Represents a collection of Person objects.</summary> public class Persons : List<Person> { } /// <summary> /// A Data Record class. /// </summary> public class Person { /// <summary>Gets or sets the PersonId value. /// </summary> public Int32 PersonId { get; set; } /// <summary>Gets or sets the Name value.</summary> public String Name { get; set; } } /// <summary>Provides Person specific data manipulation methods.</summary> public class PersonManager { /// <summary>Initializes an object instance.</summary> /// <param name="dbService">The database service object.</param> public PersonManager() { DbServiceRef dbServiceRef = new DbServiceRef(); { DbService = new DbService(); }; string dataConfigName = "PersonData"; string tableName = "Person"; mDataManager = new DataManager(dbServiceRef, dataConfigName, tableName); mDataManager.MapNames("Id", "PersonId"); } // The Add(), Delete(), Load(), Retrieve() and Update() methods would go here. // These are listed under the DataManager methods with the same names. /// <summary>Gets or sets the non-select affected record count.</summary> public int AffectedCount { get; set; } /// <summary>Gets a reference to the Data Definition columns collection.</summary> public DbColumns DataDefinition { get { return mDataManager.DataDefinition; } } /// <summary>Gets or sets the last SQL statement.</summary> public string SQLStatement { get; set; } private DataManager mDataManager; } // The DbService object retrieves the data configuration from a file named // "DataConfigs.xml". This file must be in the same folder as the application. // This is the XML file layout. <? xml version="1.0"?> <DataConfigs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <DataConfig> <Name>PersonData</Name> <DbServer>Machine_Name\SQL_Instance_Name</DbServer> <Database>Database_Name</Database> <ConnectionType>SQLServer</ConnectionType> </DataConfig> </DataConfigs>