📄 _employeeterritories.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 EmployeeTerritoriesSchema : NCI.EasyObjects.Schema
{
private static ArrayList _entries;
public static SchemaItem EmployeeID = new SchemaItem("EmployeeID", DbType.Int32, false, false, false, true, true, false);
public static SchemaItem TerritoryID = new SchemaItem("TerritoryID", DbType.String, SchemaItemJustify.None, 20, false, true, true, false);
public override ArrayList SchemaEntries
{
get
{
if (_entries == null )
{
_entries = new ArrayList();
_entries.Add(EmployeeTerritoriesSchema.EmployeeID);
_entries.Add(EmployeeTerritoriesSchema.TerritoryID);
}
return _entries;
}
}
public static bool HasAutoKey
{
get { return false; }
}
public static bool HasRowID
{
get { return false; }
}
}
#endregion
public abstract class _EmployeeTerritories : EasyObject
{
public _EmployeeTerritories()
{
EmployeeTerritoriesSchema _schema = new EmployeeTerritoriesSchema();
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>
/// <param name="TerritoryID"></param>
/// <returns>A Boolean indicating success or failure of the query</returns>
public bool LoadByPrimaryKey(int EmployeeID, string TerritoryID)
{
switch(this.DefaultCommandType)
{
case CommandType.StoredProcedure:
ListDictionary parameters = new ListDictionary();
// Add in parameters
parameters.Add(EmployeeTerritoriesSchema.EmployeeID.FieldName, EmployeeID);
parameters.Add(EmployeeTerritoriesSchema.TerritoryID.FieldName, TerritoryID);
return base.LoadFromSql(this.SchemaStoredProcedureWithSeparator + "daab_GetEmployeeTerritories", parameters, CommandType.StoredProcedure);
case CommandType.Text:
this.Query.ClearAll();
this.Where.WhereClauseReset();
this.Where.EmployeeID.Value = EmployeeID;
this.Where.TerritoryID.Value = TerritoryID;
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_GetAllEmployeeTerritories", 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_AddEmployeeTerritories";
dbCommand = db.GetStoredProcCommand(sqlCommand);
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)
{
}
else
{
}
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_UpdateEmployeeTerritories";
dbCommand = db.GetStoredProcCommand(sqlCommand);
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;
this.Where.TerritoryID.Operator = WhereParameter.Operand.Equal;
dbCommand = this.Query.GetUpdateCommandWrapper();
dbCommand.Parameters.Clear();
CreateParameters(db, dbCommand);
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_DeleteEmployeeTerritories";
dbCommand = db.GetStoredProcCommand(sqlCommand);
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Current);
db.AddInParameter(dbCommand, "TerritoryID", DbType.String, "TerritoryID", DataRowVersion.Current);
return dbCommand;
case CommandType.Text:
this.Query.ClearAll();
this.Where.WhereClauseReset();
this.Where.EmployeeID.Operator = WhereParameter.Operand.Equal;
this.Where.TerritoryID.Operator = WhereParameter.Operand.Equal;
dbCommand = this.Query.GetDeleteCommandWrapper();
dbCommand.Parameters.Clear();
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Current);
db.AddInParameter(dbCommand, "TerritoryID", DbType.String, "TerritoryID", DataRowVersion.Current);
return dbCommand;
default:
throw new ArgumentException("Invalid CommandType", "commandType");
}
}
private void CreateParameters(Database db, DbCommand dbCommand)
{
db.AddInParameter(dbCommand, "EmployeeID", DbType.Int32, "EmployeeID", DataRowVersion.Current);
db.AddInParameter(dbCommand, "TerritoryID", DbType.String, "TerritoryID", DataRowVersion.Current);
}
#region Properties
public virtual int EmployeeID
{
get
{
return this.GetInteger(EmployeeTerritoriesSchema.EmployeeID.FieldName);
}
set
{
this.SetInteger(EmployeeTerritoriesSchema.EmployeeID.FieldName, value);
}
}
public virtual string TerritoryID
{
get
{
return this.GetString(EmployeeTerritoriesSchema.TerritoryID.FieldName);
}
set
{
this.SetString(EmployeeTerritoriesSchema.TerritoryID.FieldName, value);
}
}
public override string TableName
{
get { return "EmployeeTerritories"; }
}
#endregion
#region String Properties
public virtual string s_EmployeeID
{
get
{
return this.IsColumnNull(EmployeeTerritoriesSchema.EmployeeID.FieldName) ? string.Empty : base.GetIntegerAsString(EmployeeTerritoriesSchema.EmployeeID.FieldName);
}
set
{
if(string.Empty == value)
this.SetColumnNull(EmployeeTerritoriesSchema.EmployeeID.FieldName);
else
this.EmployeeID = base.SetIntegerAsString(EmployeeTerritoriesSchema.EmployeeID.FieldName, value);
}
}
public virtual string s_TerritoryID
{
get
{
return this.IsColumnNull(EmployeeTerritoriesSchema.TerritoryID.FieldName) ? string.Empty : base.GetStringAsString(EmployeeTerritoriesSchema.TerritoryID.FieldName);
}
set
{
if(string.Empty == value)
this.SetColumnNull(EmployeeTerritoriesSchema.TerritoryID.FieldName);
else
this.TerritoryID = base.SetStringAsString(EmployeeTerritoriesSchema.TerritoryID.FieldName, value);
}
}
#endregion
#region Where Clause
public class WhereClause
{
public WhereClause(EasyObject entity)
{
this._entity = entity;
}
public TearOffWhereParameter TearOff
{
get
{
if(_tearOff == null)
{
_tearOff = new TearOffWhereParameter(this);
}
return _tearOff;
}
}
#region TearOff's
public class TearOffWhereParameter
{
public TearOffWhereParameter(WhereClause clause)
{
this._clause = clause;
}
public WhereParameter EmployeeID
{
get
{
WhereParameter wp = new WhereParameter(EmployeeTerritoriesSchema.EmployeeID);
this._clause._entity.Query.AddWhereParameter(wp);
return wp;
}
}
public WhereParameter TerritoryID
{
get
{
WhereParameter wp = new WhereParameter(EmployeeTerritoriesSchema.TerritoryID);
this._clause._entity.Query.AddWhereParameter(wp);
return wp;
}
}
private WhereClause _clause;
}
#endregion
public WhereParameter EmployeeID
{
get
{
if(_EmployeeID_W == null)
{
_EmployeeID_W = TearOff.EmployeeID;
}
return _EmployeeID_W;
}
}
public WhereParameter TerritoryID
{
get
{
if(_TerritoryID_W == null)
{
_TerritoryID_W = TearOff.TerritoryID;
}
return _TerritoryID_W;
}
}
private WhereParameter _EmployeeID_W = null;
private WhereParameter _TerritoryID_W = null;
public void WhereClauseReset()
{
_EmployeeID_W = null;
_TerritoryID_W = null;
this._entity.Query.FlushWhereParameters();
}
private EasyObject _entity;
private TearOffWhereParameter _tearOff;
}
public WhereClause Where
{
get
{
if(_whereClause == null)
{
_whereClause = new WhereClause(this);
}
return _whereClause;
}
}
private WhereClause _whereClause = null;
#endregion
#region Aggregate Clause
public class AggregateClause
{
public AggregateClause(EasyObject entity)
{
this._entity = entity;
}
public TearOffAggregateParameter TearOff
{
get
{
if(_tearOff == null)
{
_tearOff = new TearOffAggregateParameter(this);
}
return _tearOff;
}
}
#region TearOff's
public class TearOffAggregateParameter
{
public TearOffAggregateParameter(AggregateClause clause)
{
this._clause = clause;
}
public AggregateParameter EmployeeID
{
get
{
AggregateParameter ap = new AggregateParameter(EmployeeTerritoriesSchema.EmployeeID);
this._clause._entity.Query.AddAggregateParameter(ap);
return ap;
}
}
public AggregateParameter TerritoryID
{
get
{
AggregateParameter ap = new AggregateParameter(EmployeeTerritoriesSchema.TerritoryID);
this._clause._entity.Query.AddAggregateParameter(ap);
return ap;
}
}
private AggregateClause _clause;
}
#endregion
public AggregateParameter EmployeeID
{
get
{
if(_EmployeeID_W == null)
{
_EmployeeID_W = TearOff.EmployeeID;
}
return _EmployeeID_W;
}
}
public AggregateParameter TerritoryID
{
get
{
if(_TerritoryID_W == null)
{
_TerritoryID_W = TearOff.TerritoryID;
}
return _TerritoryID_W;
}
}
private AggregateParameter _EmployeeID_W = null;
private AggregateParameter _TerritoryID_W = null;
public void AggregateClauseReset()
{
_EmployeeID_W = null;
_TerritoryID_W = null;
this._entity.Query.FlushAggregateParameters();
}
private EasyObject _entity;
private TearOffAggregateParameter _tearOff;
}
public AggregateClause Aggregate
{
get
{
if(_aggregateClause == null)
{
_aggregateClause = new AggregateClause(this);
}
return _aggregateClause;
}
}
private AggregateClause _aggregateClause = null;
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -