📄 _employees.cs
字号:
/*
'===============================================================================
' Generated From - CSharp_EasyObject_BusinessEntity.vbgen
'
' ** IMPORTANT **
' How to Generate your stored procedures:
'
' SQL = SQL_DAAB_StoredProcs.vbgen
'
' This object is 'abstract' which means you need to inherit from it to be able
' to instantiate it. This is very easily done. You can override properties and
' methods in your derived class, this allows you to regenerate this class at any
' time and not worry about overwriting custom code.
'
' NEVER EDIT THIS FILE.
'
' public class YourObject : _YourObject
' {
'
' }
'
'===============================================================================
*/
// Generated by MyGeneration Version # (1.2.0.2)
using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Xml;
using System.IO;
using Microsoft.Practices.EnterpriseLibrary.Data;
using NCI.EasyObjects;
namespace EasyObjectsQuickStart.BLL
{
#region Schema
public class EmployeesSchema : NCI.EasyObjects.Schema
{
private static ArrayList _entries;
public static SchemaItem EmployeeID = new SchemaItem("EmployeeID", DbType.Int32, true, false, false, true, true, false);
public static SchemaItem LastName = new SchemaItem("LastName", DbType.String, SchemaItemJustify.None, 20, false, false, false, false);
public static SchemaItem FirstName = new SchemaItem("FirstName", DbType.String, SchemaItemJustify.None, 10, false, false, false, false);
public static SchemaItem Title = new SchemaItem("Title", DbType.String, SchemaItemJustify.None, 30, true, false, false, false);
public static SchemaItem TitleOfCourtesy = new SchemaItem("TitleOfCourtesy", DbType.String, SchemaItemJustify.None, 25, true, false, false, false);
public static SchemaItem BirthDate = new SchemaItem("BirthDate", DbType.DateTime, false, true, false, false, false, false);
public static SchemaItem HireDate = new SchemaItem("HireDate", DbType.DateTime, false, true, false, false, false, false);
public static SchemaItem Address = new SchemaItem("Address", DbType.String, SchemaItemJustify.None, 60, true, false, false, false);
public static SchemaItem City = new SchemaItem("City", DbType.String, SchemaItemJustify.None, 15, true, false, false, false);
public static SchemaItem Region = new SchemaItem("Region", DbType.String, SchemaItemJustify.None, 15, true, false, false, false);
public static SchemaItem PostalCode = new SchemaItem("PostalCode", DbType.String, SchemaItemJustify.None, 10, true, false, false, false);
public static SchemaItem Country = new SchemaItem("Country", DbType.String, SchemaItemJustify.None, 15, true, false, false, false);
public static SchemaItem HomePhone = new SchemaItem("HomePhone", DbType.String, SchemaItemJustify.None, 24, true, false, false, false);
public static SchemaItem Extension = new SchemaItem("Extension", DbType.String, SchemaItemJustify.None, 4, true, false, false, false);
public static SchemaItem Photo = new SchemaItem("Photo", DbType.Binary, false, true, false, false, false, false);
public static SchemaItem Notes = new SchemaItem("Notes", DbType.String, SchemaItemJustify.None, 1073741823, true, false, false, false);
public static SchemaItem ReportsTo = new SchemaItem("ReportsTo", DbType.Int32, false, true, false, false, true, false);
public static SchemaItem PhotoPath = new SchemaItem("PhotoPath", DbType.String, SchemaItemJustify.None, 255, true, false, false, false);
public override ArrayList SchemaEntries
{
get
{
if (_entries == null )
{
_entries = new ArrayList();
_entries.Add(EmployeesSchema.EmployeeID);
_entries.Add(EmployeesSchema.LastName);
_entries.Add(EmployeesSchema.FirstName);
_entries.Add(EmployeesSchema.Title);
_entries.Add(EmployeesSchema.TitleOfCourtesy);
_entries.Add(EmployeesSchema.BirthDate);
_entries.Add(EmployeesSchema.HireDate);
_entries.Add(EmployeesSchema.Address);
_entries.Add(EmployeesSchema.City);
_entries.Add(EmployeesSchema.Region);
_entries.Add(EmployeesSchema.PostalCode);
_entries.Add(EmployeesSchema.Country);
_entries.Add(EmployeesSchema.HomePhone);
_entries.Add(EmployeesSchema.Extension);
_entries.Add(EmployeesSchema.Photo);
_entries.Add(EmployeesSchema.Notes);
_entries.Add(EmployeesSchema.ReportsTo);
_entries.Add(EmployeesSchema.PhotoPath);
}
return _entries;
}
}
public static bool HasAutoKey
{
get { return true; }
}
public static bool HasRowID
{
get { return false; }
}
}
#endregion
public abstract class _Employees : EasyObject
{
public _Employees()
{
EmployeesSchema _schema = new EmployeesSchema();
this.SchemaEntries = _schema.SchemaEntries;
this.SchemaGlobal = "dbo";
}
public override void FlushData()
{
this._whereClause = null;
this._aggregateClause = null;
base.FlushData();
}
/// <summary>
/// Loads the business object with info from the database, based on the requested primary key.
/// </summary>
/// <param name="EmployeeID"></param>
/// <returns>A Boolean indicating success or failure of the query</returns>
public bool LoadByPrimaryKey(int EmployeeID)
{
switch(this.DefaultCommandType)
{
case CommandType.StoredProcedure:
ListDictionary parameters = new ListDictionary();
// Add in parameters
parameters.Add(EmployeesSchema.EmployeeID.FieldName, EmployeeID);
return base.LoadFromSql(this.SchemaStoredProcedureWithSeparator + "daab_GetEmployees", parameters, CommandType.StoredProcedure);
case CommandType.Text:
this.Query.ClearAll();
this.Where.WhereClauseReset();
this.Where.EmployeeID.Value = EmployeeID;
return this.Query.Load();
default:
throw new ArgumentException("Invalid CommandType", "commandType");
}
}
/// <summary>
/// Loads all records from the table.
/// </summary>
/// <returns>A Boolean indicating success or failure of the query</returns>
public bool LoadAll()
{
switch(this.DefaultCommandType)
{
case CommandType.StoredProcedure:
return base.LoadFromSql(this.SchemaStoredProcedureWithSeparator + "daab_GetAllEmployees", null, CommandType.StoredProcedure);
case CommandType.Text:
this.Query.ClearAll();
this.Where.WhereClauseReset();
return this.Query.Load();
default:
throw new ArgumentException("Invalid CommandType", "commandType");
}
}
/// <summary>
/// Adds a new record to the internal table.
/// </summary>
public override void AddNew()
{
base.AddNew();
this.ApplyDefaults();
}
/// <summary>
/// Apply any default values to columns
/// </summary>
protected override void ApplyDefaults()
{
}
protected override DbCommand GetInsertCommand(CommandType commandType)
{
DbCommand dbCommand;
// Create the Database object, using the default database service. The
// default database service is determined through configuration.
Database db = GetDatabase();
switch(commandType)
{
case CommandType.StoredProcedure:
string sqlCommand = this.SchemaStoredProcedureWithSeparator + "daab_AddEmployees";
dbCommand = db.GetStoredProcCommand(sqlCommand);
db.AddParameter(dbCommand, "EmployeeID", DbType.Int32, 0, ParameterDirection.Output, true, 0, 0, "EmployeeID", DataRowVersion.Default, Convert.DBNull);
CreateParameters(db, dbCommand);
return dbCommand;
case CommandType.Text:
this.Query.ClearAll();
this.Where.WhereClauseReset();
foreach(SchemaItem item in this.SchemaEntries)
{
if (!item.IsComputed)
{
if ((item.IsAutoKey && this.IdentityInsert) || !item.IsAutoKey)
{
this.Query.AddInsertColumn(item);
}
}
}
dbCommand = this.Query.GetInsertCommandWrapper();
dbCommand.Parameters.Clear();
if (this.IdentityInsert)
{
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Default);
}
else
{
db.AddParameter(dbCommand, "EmployeeID", DbType.Int32, 0, ParameterDirection.Output, true, 0, 0, "EmployeeID", DataRowVersion.Default, Convert.DBNull);
}
CreateParameters(db, dbCommand);
return dbCommand;
default:
throw new ArgumentException("Invalid CommandType", "commandType");
}
}
protected override DbCommand GetUpdateCommand(CommandType commandType)
{
DbCommand dbCommand;
// Create the Database object, using the default database service. The
// default database service is determined through configuration.
Database db = GetDatabase();
switch(commandType)
{
case CommandType.StoredProcedure:
string sqlCommand = this.SchemaStoredProcedureWithSeparator + "daab_UpdateEmployees";
dbCommand = db.GetStoredProcCommand(sqlCommand);
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Current);
CreateParameters(db, dbCommand);
return dbCommand;
case CommandType.Text:
this.Query.ClearAll();
foreach(SchemaItem item in this.SchemaEntries)
{
if (!(item.IsAutoKey || item.IsComputed))
{
this.Query.AddUpdateColumn(item);
}
}
this.Where.WhereClauseReset();
this.Where.EmployeeID.Operator = WhereParameter.Operand.Equal;
dbCommand = this.Query.GetUpdateCommandWrapper();
dbCommand.Parameters.Clear();
CreateParameters(db, dbCommand);
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Current);
return dbCommand;
default:
throw new ArgumentException("Invalid CommandType", "commandType");
}
}
protected override DbCommand GetDeleteCommand(CommandType commandType)
{
DbCommand dbCommand;
// Create the Database object, using the default database service. The
// default database service is determined through configuration.
Database db = GetDatabase();
switch(commandType)
{
case CommandType.StoredProcedure:
string sqlCommand = this.SchemaStoredProcedureWithSeparator + "daab_DeleteEmployees";
dbCommand = db.GetStoredProcCommand(sqlCommand);
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Current);
return dbCommand;
case CommandType.Text:
this.Query.ClearAll();
this.Where.WhereClauseReset();
this.Where.EmployeeID.Operator = WhereParameter.Operand.Equal;
dbCommand = this.Query.GetDeleteCommandWrapper();
dbCommand.Parameters.Clear();
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Current);
return dbCommand;
default:
throw new ArgumentException("Invalid CommandType", "commandType");
}
}
private void CreateParameters(Database db, DbCommand dbCommand)
{
db.AddInParameter(dbCommand, "LastName", DbType.String, "LastName", DataRowVersion.Current);
db.AddInParameter(dbCommand, "FirstName", DbType.String, "FirstName", DataRowVersion.Current);
db.AddInParameter(dbCommand, "Title", DbType.String, "Title", DataRowVersion.Current);
db.AddInParameter(dbCommand, "TitleOfCourtesy", DbType.String, "TitleOfCourtesy", DataRowVersion.Current);
db.AddInParameter(dbCommand, "BirthDate", DbType.DateTime, "BirthDate", DataRowVersion.Current);
db.AddInParameter(dbCommand, "HireDate", DbType.DateTime, "HireDate", DataRowVersion.Current);
db.AddInParameter(dbCommand, "Address", DbType.String, "Address", DataRowVersion.Current);
db.AddInParameter(dbCommand, "City", DbType.String, "City", DataRowVersion.Current);
db.AddInParameter(dbCommand, "Region", DbType.String, "Region", DataRowVersion.Current);
db.AddInParameter(dbCommand, "PostalCode", DbType.String, "PostalCode", DataRowVersion.Current);
db.AddInParameter(dbCommand, "Country", DbType.String, "Country", DataRowVersion.Current);
db.AddInParameter(dbCommand, "HomePhone", DbType.String, "HomePhone", DataRowVersion.Current);
db.AddInParameter(dbCommand, "Extension", DbType.String, "Extension", DataRowVersion.Current);
db.AddInParameter(dbCommand, "Photo", DbType.Binary, "Photo", DataRowVersion.Current);
db.AddInParameter(dbCommand, "Notes", DbType.String, "Notes", DataRowVersion.Current);
db.AddInParameter(dbCommand, "ReportsTo", DbType.Int32, "ReportsTo", DataRowVersion.Current);
db.AddInParameter(dbCommand, "PhotoPath", DbType.String, "PhotoPath", DataRowVersion.Current);
}
#region Properties
public virtual int EmployeeID
{
get
{
return this.GetInteger(EmployeesSchema.EmployeeID.FieldName);
}
set
{
this.SetInteger(EmployeesSchema.EmployeeID.FieldName, value);
}
}
public virtual string LastName
{
get
{
return this.GetString(EmployeesSchema.LastName.FieldName);
}
set
{
this.SetString(EmployeesSchema.LastName.FieldName, value);
}
}
public virtual string FirstName
{
get
{
return this.GetString(EmployeesSchema.FirstName.FieldName);
}
set
{
this.SetString(EmployeesSchema.FirstName.FieldName, value);
}
}
public virtual string Title
{
get
{
return this.GetString(EmployeesSchema.Title.FieldName);
}
set
{
this.SetString(EmployeesSchema.Title.FieldName, value);
}
}
public virtual string TitleOfCourtesy
{
get
{
return this.GetString(EmployeesSchema.TitleOfCourtesy.FieldName);
}
set
{
this.SetString(EmployeesSchema.TitleOfCourtesy.FieldName, value);
}
}
public virtual DateTime BirthDate
{
get
{
return this.GetDateTime(EmployeesSchema.BirthDate.FieldName);
}
set
{
this.SetDateTime(EmployeesSchema.BirthDate.FieldName, value);
}
}
public virtual DateTime HireDate
{
get
{
return this.GetDateTime(EmployeesSchema.HireDate.FieldName);
}
set
{
this.SetDateTime(EmployeesSchema.HireDate.FieldName, value);
}
}
public virtual string Address
{
get
{
return this.GetString(EmployeesSchema.Address.FieldName);
}
set
{
this.SetString(EmployeesSchema.Address.FieldName, value);
}
}
public virtual string City
{
get
{
return this.GetString(EmployeesSchema.City.FieldName);
}
set
{
this.SetString(EmployeesSchema.City.FieldName, value);
}
}
public virtual string Region
{
get
{
return this.GetString(EmployeesSchema.Region.FieldName);
}
set
{
this.SetString(EmployeesSchema.Region.FieldName, value);
}
}
public virtual string PostalCode
{
get
{
return this.GetString(EmployeesSchema.PostalCode.FieldName);
}
set
{
this.SetString(EmployeesSchema.PostalCode.FieldName, value);
}
}
public virtual string Country
{
get
{
return this.GetString(EmployeesSchema.Country.FieldName);
}
set
{
this.SetString(EmployeesSchema.Country.FieldName, value);
}
}
public virtual string HomePhone
{
get
{
return this.GetString(EmployeesSchema.HomePhone.FieldName);
}
set
{
this.SetString(EmployeesSchema.HomePhone.FieldName, value);
}
}
public virtual string Extension
{
get
{
return this.GetString(EmployeesSchema.Extension.FieldName);
}
set
{
this.SetString(EmployeesSchema.Extension.FieldName, value);
}
}
public virtual byte[] Photo
{
get
{
return this.GetByteArray(EmployeesSchema.Photo.FieldName);
}
set
{
this.SetByteArray(EmployeesSchema.Photo.FieldName, value);
}
}
public virtual string Notes
{
get
{
return this.GetString(EmployeesSchema.Notes.FieldName);
}
set
{
this.SetString(EmployeesSchema.Notes.FieldName, value);
}
}
public virtual int ReportsTo
{
get
{
return this.GetInteger(EmployeesSchema.ReportsTo.FieldName);
}
set
{
this.SetInteger(EmployeesSchema.ReportsTo.FieldName, value);
}
}
public virtual string PhotoPath
{
get
{
return this.GetString(EmployeesSchema.PhotoPath.FieldName);
}
set
{
this.SetString(EmployeesSchema.PhotoPath.FieldName, value);
}
}
public override string TableName
{
get { return "Employees"; }
}
#endregion
#region String Properties
public virtual string s_EmployeeID
{
get
{
return this.IsColumnNull(EmployeesSchema.EmployeeID.FieldName) ? string.Empty : base.GetIntegerAsString(EmployeesSchema.EmployeeID.FieldName);
}
set
{
if(string.Empty == value)
this.SetColumnNull(EmployeesSchema.EmployeeID.FieldName);
else
this.EmployeeID = base.SetIntegerAsString(EmployeesSchema.EmployeeID.FieldName, value);
}
}
public virtual string s_LastName
{
get
{
return this.IsColumnNull(EmployeesSchema.LastName.FieldName) ? string.Empty : base.GetStringAsString(EmployeesSchema.LastName.FieldName);
}
set
{
if(string.Empty == value)
this.SetColumnNull(EmployeesSchema.LastName.FieldName);
else
this.LastName = base.SetStringAsString(EmployeesSchema.LastName.FieldName, value);
}
}
public virtual string s_FirstName
{
get
{
return this.IsColumnNull(EmployeesSchema.FirstName.FieldName) ? string.Empty : base.GetStringAsString(EmployeesSchema.FirstName.FieldName);
}
set
{
if(string.Empty == value)
this.SetColumnNull(EmployeesSchema.FirstName.FieldName);
else
this.FirstName = base.SetStringAsString(EmployeesSchema.FirstName.FieldName, value);
}
}
public virtual string s_Title
{
get
{
return this.IsColumnNull(EmployeesSchema.Title.FieldName) ? string.Empty : base.GetStringAsString(EmployeesSchema.Title.FieldName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -