⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _customercustomerdemo.cs

📁 EasyObjects 是ORM的典型应用的例子是学习研究的很好的范例
💻 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 CustomerCustomerDemoSchema : NCI.EasyObjects.Schema
	{
		private static ArrayList _entries;
		public static SchemaItem CustomerID = new SchemaItem("CustomerID", DbType.StringFixedLength, SchemaItemJustify.None, 5, false, true, true, false);
		public static SchemaItem CustomerTypeID = new SchemaItem("CustomerTypeID", DbType.StringFixedLength, SchemaItemJustify.None, 10, false, true, true, false);

		public override ArrayList SchemaEntries
		{
			get
			{
				if (_entries == null )
				{
					_entries = new ArrayList();
					_entries.Add(CustomerCustomerDemoSchema.CustomerID);
					_entries.Add(CustomerCustomerDemoSchema.CustomerTypeID);
				}
				return _entries;
			}
		}
		
		public static bool HasAutoKey 
		{
			get { return false;	}
		}

		public static bool HasRowID 
		{
			get { return false;	}
		}
	}
	#endregion

	public abstract class _CustomerCustomerDemo : EasyObject
	{

		public _CustomerCustomerDemo()
		{
			CustomerCustomerDemoSchema _schema = new CustomerCustomerDemoSchema();
			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="CustomerID"></param>
		/// <param name="CustomerTypeID"></param>
		/// <returns>A Boolean indicating success or failure of the query</returns>
		public bool LoadByPrimaryKey(string CustomerID, string CustomerTypeID)
		{
			switch(this.DefaultCommandType)
			{
				case CommandType.StoredProcedure:
					ListDictionary parameters = new ListDictionary();

					// Add in parameters
					parameters.Add(CustomerCustomerDemoSchema.CustomerID.FieldName, CustomerID);
					parameters.Add(CustomerCustomerDemoSchema.CustomerTypeID.FieldName, CustomerTypeID);

					return base.LoadFromSql(this.SchemaStoredProcedureWithSeparator + "daab_GetCustomerCustomerDemo", parameters, CommandType.StoredProcedure);

				case CommandType.Text:
					this.Query.ClearAll();
					this.Where.WhereClauseReset();
					this.Where.CustomerID.Value = CustomerID;
					this.Where.CustomerTypeID.Value = CustomerTypeID;
					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_GetAllCustomerCustomerDemo", 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_AddCustomerCustomerDemo";
					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_UpdateCustomerCustomerDemo";
					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.CustomerID.Operator = WhereParameter.Operand.Equal;
					this.Where.CustomerTypeID.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_DeleteCustomerCustomerDemo";
					dbCommand = db.GetStoredProcCommand(sqlCommand);
					db.AddInParameter(dbCommand, "CustomerID", DbType.StringFixedLength, "CustomerID", DataRowVersion.Current);
					db.AddInParameter(dbCommand, "CustomerTypeID", DbType.StringFixedLength, "CustomerTypeID", DataRowVersion.Current);
					
					return dbCommand;

				case CommandType.Text:
					this.Query.ClearAll();
					this.Where.WhereClauseReset();
					this.Where.CustomerID.Operator = WhereParameter.Operand.Equal;
					this.Where.CustomerTypeID.Operator = WhereParameter.Operand.Equal;
					dbCommand = this.Query.GetDeleteCommandWrapper();

					dbCommand.Parameters.Clear();
					db.AddInParameter(dbCommand, "CustomerID", DbType.StringFixedLength, "CustomerID", DataRowVersion.Current);
					db.AddInParameter(dbCommand, "CustomerTypeID", DbType.StringFixedLength, "CustomerTypeID", DataRowVersion.Current);
					
					return dbCommand;

				default:
					throw new ArgumentException("Invalid CommandType", "commandType");
			}
		}

		private void CreateParameters(Database db, DbCommand dbCommand)
		{
			db.AddInParameter(dbCommand, "CustomerID", DbType.StringFixedLength, "CustomerID", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "CustomerTypeID", DbType.StringFixedLength, "CustomerTypeID", DataRowVersion.Current);
		}
		
		#region Properties
		public virtual string CustomerID
		{
			get
			{
				return this.GetString(CustomerCustomerDemoSchema.CustomerID.FieldName);
	    	}
			set
			{
				this.SetString(CustomerCustomerDemoSchema.CustomerID.FieldName, value);
			}
		}
		public virtual string CustomerTypeID
		{
			get
			{
				return this.GetString(CustomerCustomerDemoSchema.CustomerTypeID.FieldName);
	    	}
			set
			{
				this.SetString(CustomerCustomerDemoSchema.CustomerTypeID.FieldName, value);
			}
		}

		public override string TableName
		{
			get { return "CustomerCustomerDemo"; }
		}
		
		#endregion		
		
		#region String Properties
		public virtual string s_CustomerID
		{
			get
			{
			    return this.IsColumnNull(CustomerCustomerDemoSchema.CustomerID.FieldName) ? string.Empty : base.GetStringAsString(CustomerCustomerDemoSchema.CustomerID.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(CustomerCustomerDemoSchema.CustomerID.FieldName);
			    else
			        this.CustomerID = base.SetStringAsString(CustomerCustomerDemoSchema.CustomerID.FieldName, value);
			}
		}
		public virtual string s_CustomerTypeID
		{
			get
			{
			    return this.IsColumnNull(CustomerCustomerDemoSchema.CustomerTypeID.FieldName) ? string.Empty : base.GetStringAsString(CustomerCustomerDemoSchema.CustomerTypeID.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(CustomerCustomerDemoSchema.CustomerTypeID.FieldName);
			    else
			        this.CustomerTypeID = base.SetStringAsString(CustomerCustomerDemoSchema.CustomerTypeID.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 CustomerID
				{
					get
					{
							WhereParameter wp = new WhereParameter(CustomerCustomerDemoSchema.CustomerID);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter CustomerTypeID
				{
					get
					{
							WhereParameter wp = new WhereParameter(CustomerCustomerDemoSchema.CustomerTypeID);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}


				private WhereClause _clause;
			}
			#endregion
		
			public WhereParameter CustomerID
		    {
				get
		        {
					if(_CustomerID_W == null)
	        	    {
						_CustomerID_W = TearOff.CustomerID;
					}
					return _CustomerID_W;
				}
			}

			public WhereParameter CustomerTypeID
		    {
				get
		        {
					if(_CustomerTypeID_W == null)
	        	    {
						_CustomerTypeID_W = TearOff.CustomerTypeID;
					}
					return _CustomerTypeID_W;
				}
			}

			private WhereParameter _CustomerID_W = null;
			private WhereParameter _CustomerTypeID_W = null;

			public void WhereClauseReset()
			{
				_CustomerID_W = null;
				_CustomerTypeID_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 CustomerID
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(CustomerCustomerDemoSchema.CustomerID);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter CustomerTypeID
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(CustomerCustomerDemoSchema.CustomerTypeID);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}


				private AggregateClause _clause;
			}
			#endregion
		
			public AggregateParameter CustomerID
		    {
				get
		        {
					if(_CustomerID_W == null)
	        	    {
						_CustomerID_W = TearOff.CustomerID;
					}
					return _CustomerID_W;
				}
			}

			public AggregateParameter CustomerTypeID
		    {
				get
		        {
					if(_CustomerTypeID_W == null)
	        	    {
						_CustomerTypeID_W = TearOff.CustomerTypeID;
					}
					return _CustomerTypeID_W;
				}
			}

			private AggregateParameter _CustomerID_W = null;
			private AggregateParameter _CustomerTypeID_W = null;

			public void AggregateClauseReset()
			{
				_CustomerID_W = null;
				_CustomerTypeID_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 + -