I don't have much experience of C# & Database. My chef engineer has built tables in a database. In C# code he has built a class for each table with all the information that is already in the database table (see code extract). I am wondering if this is good practice and if there isn't a proper and easier way to have table information in one place. Are there easy to use tools that can create a table class out of a table definition? Is something built in Visual Studio? Also he programmed stored procedures for each table to access or store one row. So if there would be a future change in the schema (one row of a table), this demands altering three different parts. I wonder if this is good practice.
Class code extract:
public class Users: DataObjectBase
{
#region Ctor
public Users(string connString) : base()
{
_objName = "Users";
_connectionString = connString;
_columnNames = new string[] { "UserID", "FirstName", "LastName", "LoginName", "PWHash", "MediaID", "IsActive" };
_columnSqlTypes = new SqlDbType[] { SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.BigInt, SqlDbType.Bit };
_columnTypes = new string[] { "System.Int32", "System.String", "System.String", "System.String", "System.String", "System.Int64", "System.Boolean"};
_columnSizes = new int[] { 4, 100, 100, 100, 40, 8, 1 };
_fieldCount = 7;
base.Initialize();
//("Users", connString);
}
.... I want to learn doing it the proper way. Please describe it easy, as I don't understand some technical terms yet. Thanks for your patience and any hints or reccomondations.
To built a database application and learning to handle database tables efficiently.