// ======================================================================== // 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 { /// /// TextMSteps Generated by MyGeneration using the CSLA Object Mapping template /// [Serializable()] public partial class TextMSteps : BusinessListBase { #region Business Methods private string _errorMessage = string.Empty; public string ErrorMessage { get { return _errorMessage; } } // One To Many public new TextMStep this[int stepID] { get { foreach (TextMStep step in this) if (step.StepID == stepID) return step; return null; } } public TextMStep GetItem(int stepID) { foreach (TextMStep step in this) if (step.StepID == stepID) return step; return null; } public TextMStep Add() { TextMStep step = TextMStep.New(); this.Add(step); return step; } public void Remove(int stepID) { foreach (TextMStep step in this) { if (step.StepID == stepID) { Remove(step); break; } } } public bool Contains(int stepID) { foreach (TextMStep step in this) if (step.StepID == stepID) return true; return false; } public bool ContainsDeleted(int stepID) { foreach (TextMStep step in DeletedList) if (step.StepID == stepID) return true; return false; } #endregion #region Factory Methods internal static TextMSteps New() { return new TextMSteps(); } internal static TextMSteps Get(SafeDataReader dr) { return new TextMSteps(dr); } private TextMSteps() { MarkAsChild(); } private TextMSteps(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(TextMStep.Get(dr)); this.RaiseListChangedEvents = true; } internal void Update(TextM textM, SqlConnection cn) { this.RaiseListChangedEvents = false; try { // update (thus deleting) any deleted child objects foreach (TextMStep obj in DeletedList) obj.DeleteSelf(textM, cn); // now that they are deleted, remove them from memory too DeletedList.Clear(); // add/update any current child objects foreach (TextMStep obj in this) { if (obj.IsNew) obj.Insert(textM, cn); else obj.Update(textM, cn); } } finally { this.RaiseListChangedEvents = true; } } #endregion } // Class } // Namespace