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