/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.RosterType object to update.</param>
		/// <remarks>
		///		After updating the datasource, the ClinicDoctor.Entities.RosterType object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, ClinicDoctor.Entities.RosterType entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.RosterType_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.Int64, entity.Id );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@IsBooked", DbType.Boolean, entity.IsBooked );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Inserts a ClinicDoctor.Entities.RosterType object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.RosterType object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.RosterType object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, ClinicDoctor.Entities.RosterType entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.RosterType_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@Id", DbType.Int64, 8);
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@IsBooked", DbType.Boolean, entity.IsBooked );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			object _id = database.GetParameterValue(commandWrapper, "@Id");
			entity.Id = (System.Int64)_id;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.Appointment object to update.</param>
		/// <remarks>
		///		After updating the datasource, the ClinicDoctor.Entities.Appointment object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, ClinicDoctor.Entities.Appointment entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Appointment_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.String, entity.Id );
			database.AddInParameter(commandWrapper, "@OriginalId", DbType.String, entity.OriginalId);
			database.AddInParameter(commandWrapper, "@CustomerId", DbType.String, entity.CustomerId );
			database.AddInParameter(commandWrapper, "@CustomerName", DbType.String, entity.CustomerName );
			database.AddInParameter(commandWrapper, "@ContentId", DbType.Int64, (entity.ContentId.HasValue ? (object) entity.ContentId : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@ContentTitle", DbType.String, entity.ContentTitle );
			database.AddInParameter(commandWrapper, "@DoctorUsername", DbType.String, entity.DoctorUsername );
			database.AddInParameter(commandWrapper, "@DoctorShortName", DbType.String, entity.DoctorShortName );
			database.AddInParameter(commandWrapper, "@DoctorEmail", DbType.String, entity.DoctorEmail );
			database.AddInParameter(commandWrapper, "@RoomId", DbType.Int64, (entity.RoomId.HasValue ? (object) entity.RoomId : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@RoomTitle", DbType.String, entity.RoomTitle );
			database.AddInParameter(commandWrapper, "@NurseUsername", DbType.String, entity.NurseUsername );
			database.AddInParameter(commandWrapper, "@NurseShortName", DbType.String, entity.NurseShortName );
			database.AddInParameter(commandWrapper, "@StatusId", DbType.Int64, (entity.StatusId.HasValue ? (object) entity.StatusId : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@StatusTitle", DbType.String, entity.StatusTitle );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@StartTime", DbType.DateTime, (entity.StartTime.HasValue ? (object) entity.StartTime : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@EndTime", DbType.DateTime, (entity.EndTime.HasValue ? (object) entity.EndTime : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@IsComplete", DbType.Boolean, entity.IsComplete );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.Staff object to update.</param>
		/// <remarks>
		///		After updating the datasource, the ClinicDoctor.Entities.Staff object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, ClinicDoctor.Entities.Staff entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Staff_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.Int64, entity.Id );
			database.AddInParameter(commandWrapper, "@OriginalId", DbType.Int64, entity.OriginalId);
			database.AddInParameter(commandWrapper, "@FirstName", DbType.String, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.String, entity.LastName );
			database.AddInParameter(commandWrapper, "@ShortName", DbType.String, entity.ShortName );
			database.AddInParameter(commandWrapper, "@UserName", DbType.String, entity.UserName );
			database.AddInParameter(commandWrapper, "@Email", DbType.String, entity.Email );
			database.AddInParameter(commandWrapper, "@Address", DbType.String, entity.Address );
			database.AddInParameter(commandWrapper, "@HomePhone", DbType.String, entity.HomePhone );
			database.AddInParameter(commandWrapper, "@WorkPhone", DbType.String, entity.WorkPhone );
			database.AddInParameter(commandWrapper, "@CellPhone", DbType.String, entity.CellPhone );
			database.AddInParameter(commandWrapper, "@Birthdate", DbType.DateTime, (entity.Birthdate.HasValue ? (object) entity.Birthdate : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@IsFemale", DbType.Boolean, entity.IsFemale );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@Roles", DbType.String, entity.Roles );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Inserts a ClinicDoctor.Entities.DoctorRoster object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.DoctorRoster object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.DoctorRoster object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, ClinicDoctor.Entities.DoctorRoster entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.DoctorRoster_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.String, entity.Id );
			database.AddInParameter(commandWrapper, "@DoctorUserName", DbType.String, entity.DoctorUserName );
			database.AddInParameter(commandWrapper, "@DoctorShortName", DbType.String, entity.DoctorShortName );
			database.AddInParameter(commandWrapper, "@DoctorEmail", DbType.String, entity.DoctorEmail );
			database.AddInParameter(commandWrapper, "@RosterTypeId", DbType.Int64, entity.RosterTypeId );
			database.AddInParameter(commandWrapper, "@RosterTypeTitle", DbType.String, entity.RosterTypeTitle );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.String, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@IsBooked", DbType.Boolean, (entity.IsBooked.HasValue ? (object) entity.IsBooked  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@StartTime", DbType.DateTime, entity.StartTime );
			database.AddInParameter(commandWrapper, "@EndTime", DbType.DateTime, entity.EndTime );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsComplete", DbType.Boolean, entity.IsComplete );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Inserts a ClinicDoctor.Entities.Customer object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">ClinicDoctor.Entities.Customer object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.Customer object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, ClinicDoctor.Entities.Customer entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Customer_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.String, entity.Id );
			database.AddInParameter(commandWrapper, "@FirstName", DbType.String, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.String, entity.LastName );
			database.AddInParameter(commandWrapper, "@Address", DbType.String, entity.Address );
			database.AddInParameter(commandWrapper, "@HomePhone", DbType.String, entity.HomePhone );
			database.AddInParameter(commandWrapper, "@WorkPhone", DbType.String, entity.WorkPhone );
			database.AddInParameter(commandWrapper, "@CellPhone", DbType.String, entity.CellPhone );
			database.AddInParameter(commandWrapper, "@Birthdate", DbType.DateTime, (entity.Birthdate.HasValue ? (object) entity.Birthdate  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@IsFemale", DbType.Boolean, entity.IsFemale );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			
			entity.OriginalId = entity.Id;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}