2006-11-14 14:33:33 +00:00

123 lines
3.6 KiB
C#

// ========================================================================
// 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
{
/// <summary>
/// StepTextInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepTextInfoList : ReadOnlyListBase<StepTextInfoList, StepTextInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static StepTextInfoList Get()
{
return DataPortal.Fetch<StepTextInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static StepTextInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<StepTextInfoList>(new FilteredCriteria(<criteria>));
//}
public static StepTextInfoList GetByStep(int stepID)
{
return DataPortal.Fetch<StepTextInfoList>(new StepCriteria(stepID));
}
private StepTextInfoList()
{ /* 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 = "getStepTexts";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StepTextInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("StepTextInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StepTextInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StepCriteria
{
public StepCriteria(int stepID)
{
_StepID = stepID;
}
private int _StepID;
public int StepID
{
get { return _StepID; }
set { _StepID = value; }
}
}
private void DataPortal_Fetch(StepCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStepTextsByStep";
cm.Parameters.AddWithValue("@StepID", criteria.StepID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StepTextInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("StepTextInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StepTextInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace