// ======================================================================== // 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 { /// /// RoUsageInfoList Generated by MyGeneration using the CSLA Object Mapping template /// [Serializable()] public partial class RoUsageInfoList : ReadOnlyListBase { #region Factory Methods /// /// Return a list of all projects. /// public static RoUsageInfoList Get() { return DataPortal.Fetch(new Criteria()); } // TODO: Add alternative gets - //public static RoUsageInfoList Get() //{ // return DataPortal.Fetch(new FilteredCriteria()); //} public static RoUsageInfoList GetByStructure(int structureID) { return DataPortal.Fetch(new StructureCriteria(structureID)); } private RoUsageInfoList() { /* require use of factory methods */ } #endregion #region Data Access Portal [Serializable()] private class Criteria { /* no criteria - retrieve all rows */ } private void DataPortal_Fetch(Criteria criteria) { this.RaiseListChangedEvents = false; try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getRoUsages"; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new RoUsageInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { Database.LogException("RoUsageInfoList.DataPortal_Fetch", ex); throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } [Serializable()] private class StructureCriteria { public StructureCriteria(int structureID) { _StructureID = structureID; } private int _StructureID; public int StructureID { get { return _StructureID; } set { _StructureID = value; } } } private void DataPortal_Fetch(StructureCriteria criteria) { this.RaiseListChangedEvents = false; try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getRoUsagesByStructure"; cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new RoUsageInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { Database.LogException("RoUsageInfoList.DataPortal_Fetch", ex); throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } #endregion } // Class } // Namespace