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

📄 _suppliers.cs

📁 EasyObjects 是ORM的典型应用的例子是学习研究的很好的范例
💻 CS
📖 第 1 页 / 共 3 页
字号:
/*
'===============================================================================
'  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 SuppliersSchema : NCI.EasyObjects.Schema
	{
		private static ArrayList _entries;
		public static SchemaItem SupplierID = new SchemaItem("SupplierID", DbType.Int32, true, false, false, true, true, false);
		public static SchemaItem CompanyName = new SchemaItem("CompanyName", DbType.String, SchemaItemJustify.None, 40, false, false, false, false);
		public static SchemaItem ContactName = new SchemaItem("ContactName", DbType.String, SchemaItemJustify.None, 30, true, false, false, false);
		public static SchemaItem ContactTitle = new SchemaItem("ContactTitle", DbType.String, SchemaItemJustify.None, 30, true, 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 Phone = new SchemaItem("Phone", DbType.String, SchemaItemJustify.None, 24, true, false, false, false);
		public static SchemaItem Fax = new SchemaItem("Fax", DbType.String, SchemaItemJustify.None, 24, true, false, false, false);
		public static SchemaItem HomePage = new SchemaItem("HomePage", DbType.String, SchemaItemJustify.None, 1073741823, true, false, false, false);

		public override ArrayList SchemaEntries
		{
			get
			{
				if (_entries == null )
				{
					_entries = new ArrayList();
					_entries.Add(SuppliersSchema.SupplierID);
					_entries.Add(SuppliersSchema.CompanyName);
					_entries.Add(SuppliersSchema.ContactName);
					_entries.Add(SuppliersSchema.ContactTitle);
					_entries.Add(SuppliersSchema.Address);
					_entries.Add(SuppliersSchema.City);
					_entries.Add(SuppliersSchema.Region);
					_entries.Add(SuppliersSchema.PostalCode);
					_entries.Add(SuppliersSchema.Country);
					_entries.Add(SuppliersSchema.Phone);
					_entries.Add(SuppliersSchema.Fax);
					_entries.Add(SuppliersSchema.HomePage);
				}
				return _entries;
			}
		}
		
		public static bool HasAutoKey 
		{
			get { return true;	}
		}

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

	public abstract class _Suppliers : EasyObject
	{

		public _Suppliers()
		{
			SuppliersSchema _schema = new SuppliersSchema();
			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="SupplierID"></param>
		/// <returns>A Boolean indicating success or failure of the query</returns>
		public bool LoadByPrimaryKey(int SupplierID)
		{
			switch(this.DefaultCommandType)
			{
				case CommandType.StoredProcedure:
					ListDictionary parameters = new ListDictionary();

					// Add in parameters
					parameters.Add(SuppliersSchema.SupplierID.FieldName, SupplierID);

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

				case CommandType.Text:
					this.Query.ClearAll();
					this.Where.WhereClauseReset();
					this.Where.SupplierID.Value = SupplierID;
					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_GetAllSuppliers", 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_AddSuppliers";
					dbCommand = db.GetStoredProcCommand(sqlCommand);

					db.AddParameter(dbCommand, "SupplierID", DbType.Int32, 0, ParameterDirection.Output, true, 0, 0, "SupplierID", 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, "SupplierID", DbType.Int32, "SupplierID", DataRowVersion.Default);
					}
					else
					{
						db.AddParameter(dbCommand, "SupplierID", DbType.Int32, 0, ParameterDirection.Output, true, 0, 0, "SupplierID", 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_UpdateSuppliers";
					dbCommand = db.GetStoredProcCommand(sqlCommand);

					db.AddInParameter(dbCommand, "SupplierID", DbType.Int32, "SupplierID", 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.SupplierID.Operator = WhereParameter.Operand.Equal;
					dbCommand = this.Query.GetUpdateCommandWrapper();

					dbCommand.Parameters.Clear();
					CreateParameters(db, dbCommand);
					db.AddInParameter(dbCommand, "SupplierID", DbType.Int32, "SupplierID", 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_DeleteSuppliers";
					dbCommand = db.GetStoredProcCommand(sqlCommand);
					db.AddInParameter(dbCommand, "SupplierID", DbType.Int32, "SupplierID", DataRowVersion.Current);
					
					return dbCommand;

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

					dbCommand.Parameters.Clear();
					db.AddInParameter(dbCommand, "SupplierID", DbType.Int32, "SupplierID", DataRowVersion.Current);
					
					return dbCommand;

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

		private void CreateParameters(Database db, DbCommand dbCommand)
		{
			db.AddInParameter(dbCommand, "CompanyName", DbType.String, "CompanyName", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "ContactName", DbType.String, "ContactName", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "ContactTitle", DbType.String, "ContactTitle", 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, "Phone", DbType.String, "Phone", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "Fax", DbType.String, "Fax", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "HomePage", DbType.String, "HomePage", DataRowVersion.Current);
		}
		
		#region Properties
		public virtual int SupplierID
		{
			get
			{
				return this.GetInteger(SuppliersSchema.SupplierID.FieldName);
	    	}
			set
			{
				this.SetInteger(SuppliersSchema.SupplierID.FieldName, value);
			}
		}
		public virtual string CompanyName
		{
			get
			{
				return this.GetString(SuppliersSchema.CompanyName.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.CompanyName.FieldName, value);
			}
		}
		public virtual string ContactName
		{
			get
			{
				return this.GetString(SuppliersSchema.ContactName.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.ContactName.FieldName, value);
			}
		}
		public virtual string ContactTitle
		{
			get
			{
				return this.GetString(SuppliersSchema.ContactTitle.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.ContactTitle.FieldName, value);
			}
		}
		public virtual string Address
		{
			get
			{
				return this.GetString(SuppliersSchema.Address.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.Address.FieldName, value);
			}
		}
		public virtual string City
		{
			get
			{
				return this.GetString(SuppliersSchema.City.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.City.FieldName, value);
			}
		}
		public virtual string Region
		{
			get
			{
				return this.GetString(SuppliersSchema.Region.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.Region.FieldName, value);
			}
		}
		public virtual string PostalCode
		{
			get
			{
				return this.GetString(SuppliersSchema.PostalCode.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.PostalCode.FieldName, value);
			}
		}
		public virtual string Country
		{
			get
			{
				return this.GetString(SuppliersSchema.Country.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.Country.FieldName, value);
			}
		}
		public virtual string Phone
		{
			get
			{
				return this.GetString(SuppliersSchema.Phone.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.Phone.FieldName, value);
			}
		}
		public virtual string Fax
		{
			get
			{
				return this.GetString(SuppliersSchema.Fax.FieldName);
	    	}
			set
			{
				this.SetString(SuppliersSchema.Fax.FieldName, value);
			}
		}
		public virtual string HomePage
		{
			get
			{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -