// ======================================================================== // Copyright 2006 - Volian Enterprises, Inc. All rights reserved. // Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE // ------------------------------------------------------------------------ // $Workfile: $ $Revision: $ // $Author: $ $Date: $ // // $History: $ // ======================================================================== using System; using System.Data; using System.Data.SqlClient; using Csla; using Csla.Data; using System.Configuration; using System.IO; namespace Volian.CSLA.Library { /// /// StepStepTexts Generated by MyGeneration using the CSLA Object Mapping template /// [Serializable()] public partial class StepStepTexts : BusinessListBase { #region Business Methods private string _errorMessage = string.Empty; public string ErrorMessage { get { return _errorMessage; } } // One To Many public new StepStepText this[int stepTextMID] { get { foreach (StepStepText stepText in this) if (stepText.StepTextMID == stepTextMID) return stepText; return null; } } public StepStepText GetItem(int stepTextMID) { foreach (StepStepText stepText in this) if (stepText.StepTextMID == stepTextMID) return stepText; return null; } public StepStepText Add(int itemType, string textM) { StepStepText stepText = StepStepText.New(itemType, textM); this.Add(stepText); return stepText; } public void Remove(int stepTextMID) { foreach (StepStepText stepText in this) { if (stepText.StepTextMID == stepTextMID) { Remove(stepText); break; } } } public bool Contains(int stepTextMID) { foreach (StepStepText stepText in this) if (stepText.StepTextMID == stepTextMID) return true; return false; } public bool ContainsDeleted(int stepTextMID) { foreach (StepStepText stepText in DeletedList) if (stepText.StepTextMID == stepTextMID) return true; return false; } #endregion #region Factory Methods internal static StepStepTexts New() { return new StepStepTexts(); } internal static StepStepTexts Get(SafeDataReader dr) { return new StepStepTexts(dr); } private StepStepTexts() { MarkAsChild(); } private StepStepTexts(SafeDataReader dr) { MarkAsChild(); Fetch(dr); } #endregion #region Data Access Portal // called to load data from the database private void Fetch(SafeDataReader dr) { this.RaiseListChangedEvents = false; while (dr.Read()) this.Add(StepStepText.Get(dr)); this.RaiseListChangedEvents = true; } internal void Update(Step step, SqlConnection cn) { this.RaiseListChangedEvents = false; try { // update (thus deleting) any deleted child objects foreach (StepStepText obj in DeletedList) obj.DeleteSelf(step, cn); // now that they are deleted, remove them from memory too DeletedList.Clear(); // add/update any current child objects foreach (StepStepText obj in this) { if (obj.IsNew) obj.Insert(step, cn); else obj.Update(step, cn); } } finally { this.RaiseListChangedEvents = true; } } #endregion } // Class } // Namespace