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