Templates.cs :  » Persistence-Frameworks » ORM.NET » ORMBiz » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Persistence Frameworks » ORM.NET 
ORM.NET » ORMBiz » Templates.cs
using System;
using System.Data;
using System.Data.SqlTypes;
using System.Collections;
using System.ComponentModel;

namespace ORMBiz{


  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class ColumnOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal ColumnOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the FKTableID.
    /// </summary>
    /// <value>
    /// The underlying rows FKTableID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKTableID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKTableID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKTableID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKTableID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKTableID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKTableID"] = DBNull.Value;
        else
          row["FKTableID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the Name.
    /// </summary>
    /// <value>
    /// The underlying rows Name cell
    /// </value>
    public virtual System.String Name 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("Name") ? null : (System.String) row["Name"]; 
        else
          return row.IsNull(row.Table.Columns["Name"], DataRowVersion.Original) ? null : (System.String) row["Name", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["Name"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the FKDataTypeID.
    /// </summary>
    /// <value>
    /// The underlying rows FKDataTypeID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKDataTypeID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKDataTypeID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDataTypeID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKDataTypeID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDataTypeID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKDataTypeID"] = DBNull.Value;
        else
          row["FKDataTypeID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the Length.
    /// </summary>
    /// <value>
    /// The underlying rows Length cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 Length 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("Length"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["Length"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["Length"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["Length", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["Length"] = DBNull.Value;
        else
          row["Length"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the PrimaryKey.
    /// </summary>
    /// <value>
    /// The underlying rows PrimaryKey cell
    /// </value>
    public virtual System.String PrimaryKey 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("PrimaryKey") ? null : (System.String) row["PrimaryKey"]; 
        else
          return row.IsNull(row.Table.Columns["PrimaryKey"], DataRowVersion.Original) ? null : (System.String) row["PrimaryKey", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["PrimaryKey"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the SetAccessor.
    /// </summary>
    /// <value>
    /// The underlying rows SetAccessor cell
    /// </value>
    public virtual System.String SetAccessor 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("SetAccessor") ? null : (System.String) row["SetAccessor"]; 
        else
          return row.IsNull(row.Table.Columns["SetAccessor"], DataRowVersion.Original) ? null : (System.String) row["SetAccessor", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["SetAccessor"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the GetAccessor.
    /// </summary>
    /// <value>
    /// The underlying rows GetAccessor cell
    /// </value>
    public virtual System.String GetAccessor 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("GetAccessor") ? null : (System.String) row["GetAccessor"]; 
        else
          return row.IsNull(row.Table.Columns["GetAccessor"], DataRowVersion.Original) ? null : (System.String) row["GetAccessor", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["GetAccessor"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the RequiredForInstantiation.
    /// </summary>
    /// <value>
    /// The underlying rows RequiredForInstantiation cell
    /// </value>
    public virtual System.String RequiredForInstantiation 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("RequiredForInstantiation") ? null : (System.String) row["RequiredForInstantiation"]; 
        else
          return row.IsNull(row.Table.Columns["RequiredForInstantiation"], DataRowVersion.Original) ? null : (System.String) row["RequiredForInstantiation", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["RequiredForInstantiation"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the AccessorName.
    /// </summary>
    /// <value>
    /// The underlying rows AccessorName cell
    /// </value>
    public virtual System.String AccessorName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("AccessorName") ? null : (System.String) row["AccessorName"]; 
        else
          return row.IsNull(row.Table.Columns["AccessorName"], DataRowVersion.Original) ? null : (System.String) row["AccessorName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["AccessorName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the Nullable.
    /// </summary>
    /// <value>
    /// The underlying rows Nullable cell
    /// </value>
    public virtual System.String Nullable 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("Nullable") ? null : (System.String) row["Nullable"]; 
        else
          return row.IsNull(row.Table.Columns["Nullable"], DataRowVersion.Original) ? null : (System.String) row["Nullable", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["Nullable"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the IsIdentity.
    /// </summary>
    /// <value>
    /// The underlying rows IsIdentity cell
    /// </value>
    public virtual System.String IsIdentity 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("IsIdentity") ? null : (System.String) row["IsIdentity"]; 
        else
          return row.IsNull(row.Table.Columns["IsIdentity"], DataRowVersion.Original) ? null : (System.String) row["IsIdentity", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["IsIdentity"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the IsReadOnly.
    /// </summary>
    /// <value>
    /// The underlying rows IsReadOnly cell
    /// </value>
    public virtual System.String IsReadOnly 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("IsReadOnly") ? null : (System.String) row["IsReadOnly"]; 
        else
          return row.IsNull(row.Table.Columns["IsReadOnly"], DataRowVersion.Original) ? null : (System.String) row["IsReadOnly", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["IsReadOnly"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the DeclaredType.
    /// </summary>
    /// <value>
    /// The underlying rows DeclaredType cell
    /// </value>
    public virtual System.String DeclaredType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("DeclaredType") ? null : (System.String) row["DeclaredType"]; 
        else
          return row.IsNull(row.Table.Columns["DeclaredType"], DataRowVersion.Original) ? null : (System.String) row["DeclaredType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["DeclaredType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the Precision.
    /// </summary>
    /// <value>
    /// The underlying rows Precision cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 Precision 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("Precision"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["Precision"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["Precision"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["Precision", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["Precision"] = DBNull.Value;
        else
          row["Precision"] = value.Value; 
 
      } 
    }
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.DataType.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.DataType DataType
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKDataTypeIDColumn"]) != null)
          return new ORMBiz.DataType( DataContext, row.GetParentRow("FKDataTypeIDColumn"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKDataTypeIDColumn"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKDataTypeIDColumn"] );      
      }
    }
  
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.Table.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.Table Table
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKTableIDColumn"]) != null)
          return new ORMBiz.Table( DataContext, row.GetParentRow("FKTableIDColumn"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKTableIDColumn"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKTableIDColumn"] );      
      }
    }
  

  }



  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class DatabaseOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal DatabaseOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the DatabaseName.
    /// </summary>
    /// <value>
    /// The underlying rows DatabaseName cell
    /// </value>
    public virtual System.String DatabaseName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("DatabaseName") ? null : (System.String) row["DatabaseName"]; 
        else
          return row.IsNull(row.Table.Columns["DatabaseName"], DataRowVersion.Original) ? null : (System.String) row["DatabaseName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["DatabaseName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the DatabaseToken.
    /// </summary>
    /// <value>
    /// The underlying rows DatabaseToken cell
    /// </value>
    public virtual System.String DatabaseToken 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("DatabaseToken") ? null : (System.String) row["DatabaseToken"]; 
        else
          return row.IsNull(row.Table.Columns["DatabaseToken"], DataRowVersion.Original) ? null : (System.String) row["DatabaseToken", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["DatabaseToken"] = value; 
 
      } 
    }
    private ORMBiz.ProcedureCollection _Procedures = null;
  
    /// <summary>
    /// Refreshes the collection of Procedures from the underlying dataset
    /// </summary>
    internal void refreshProcedures()
    {
      if (_Procedures == null) _Procedures = new ORMBiz.ProcedureCollection();
      
      ((IList)_Procedures).Clear();

      DataRow[] cr = row.GetChildRows("FKDatabaseIDProcedure");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Procedure obj = new ORMBiz.Procedure(base.DataContext, chld);
        _Procedures.Add( obj );
      }
      
      // add after, so that events wont be fired
      _Procedures.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Procedures.
    /// </summary>
    public virtual ORMBiz.ProcedureCollection Procedures
    {
      get 
      { 
        if (_Procedures == null) refreshProcedures();

        return _Procedures;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Procedure to the collection.
      /// </summary>
      public virtual int AddProcedure(ORMBiz.Procedure newProcedure)
      {
        if ( _Procedures == null ) refreshProcedures();

        if ( newProcedure.row.GetParentRow(base.DataSet.Relations["FKDatabaseIDProcedure"]) == row )
          return _Procedures.IndexOf( newProcedure );

        newProcedure.row.SetParentRow(row,base.DataSet.Relations["FKDatabaseIDProcedure"]);

        int index = _Procedures.Add( newProcedure );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Procedure, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new Procedure object</returns>
      public virtual ORMBiz.Procedure NewProcedure()
      {
        if ( _Procedures == null ) refreshProcedures();

        ORMBiz.Procedure newProcedure = new ORMBiz.Procedure(base.DataContext, base.DataSet.Tables["Procedure"].NewRow());
        base.DataSet.Tables["Procedure"].Rows.Add(newProcedure.row);
        
        this.AddProcedure(newProcedure);

        return newProcedure;
      }
  
    private ORMBiz.TableCollection _Tables = null;
  
    /// <summary>
    /// Refreshes the collection of Tables from the underlying dataset
    /// </summary>
    internal void refreshTables()
    {
      if (_Tables == null) _Tables = new ORMBiz.TableCollection();
      
      ((IList)_Tables).Clear();

      DataRow[] cr = row.GetChildRows("FKDatabaseIDTable");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Table obj = new ORMBiz.Table(base.DataContext, chld);
        _Tables.Add( obj );
      }
      
      // add after, so that events wont be fired
      _Tables.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Tables.
    /// </summary>
    public virtual ORMBiz.TableCollection Tables
    {
      get 
      { 
        if (_Tables == null) refreshTables();

        return _Tables;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Table to the collection.
      /// </summary>
      public virtual int AddTable(ORMBiz.Table newTable)
      {
        if ( _Tables == null ) refreshTables();

        if ( newTable.row.GetParentRow(base.DataSet.Relations["FKDatabaseIDTable"]) == row )
          return _Tables.IndexOf( newTable );

        newTable.row.SetParentRow(row,base.DataSet.Relations["FKDatabaseIDTable"]);

        int index = _Tables.Add( newTable );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Table, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new Table object</returns>
      public virtual ORMBiz.Table NewTable()
      {
        if ( _Tables == null ) refreshTables();

        ORMBiz.Table newTable = new ORMBiz.Table(base.DataContext, base.DataSet.Tables["Table"].NewRow());
        base.DataSet.Tables["Table"].Rows.Add(newTable.row);
        
        this.AddTable(newTable);

        return newTable;
      }
  

  }



  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class DataTypeOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal DataTypeOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the SqlType.
    /// </summary>
    /// <value>
    /// The underlying rows SqlType cell
    /// </value>
    public virtual System.String SqlType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("SqlType") ? null : (System.String) row["SqlType"]; 
        else
          return row.IsNull(row.Table.Columns["SqlType"], DataRowVersion.Original) ? null : (System.String) row["SqlType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["SqlType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the NetType.
    /// </summary>
    /// <value>
    /// The underlying rows NetType cell
    /// </value>
    public virtual System.String NetType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("NetType") ? null : (System.String) row["NetType"]; 
        else
          return row.IsNull(row.Table.Columns["NetType"], DataRowVersion.Original) ? null : (System.String) row["NetType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["NetType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the XmlType.
    /// </summary>
    /// <value>
    /// The underlying rows XmlType cell
    /// </value>
    public virtual System.String XmlType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("XmlType") ? null : (System.String) row["XmlType"]; 
        else
          return row.IsNull(row.Table.Columns["XmlType"], DataRowVersion.Original) ? null : (System.String) row["XmlType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["XmlType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the NetSqlType.
    /// </summary>
    /// <value>
    /// The underlying rows NetSqlType cell
    /// </value>
    public virtual System.String NetSqlType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("NetSqlType") ? null : (System.String) row["NetSqlType"]; 
        else
          return row.IsNull(row.Table.Columns["NetSqlType"], DataRowVersion.Original) ? null : (System.String) row["NetSqlType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["NetSqlType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the SqlDbType.
    /// </summary>
    /// <value>
    /// The underlying rows SqlDbType cell
    /// </value>
    public virtual System.String SqlDbType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("SqlDbType") ? null : (System.String) row["SqlDbType"]; 
        else
          return row.IsNull(row.Table.Columns["SqlDbType"], DataRowVersion.Original) ? null : (System.String) row["SqlDbType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["SqlDbType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the OracleDbType.
    /// </summary>
    /// <value>
    /// The underlying rows OracleDbType cell
    /// </value>
    public virtual System.String OracleDbType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("OracleDbType") ? null : (System.String) row["OracleDbType"]; 
        else
          return row.IsNull(row.Table.Columns["OracleDbType"], DataRowVersion.Original) ? null : (System.String) row["OracleDbType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["OracleDbType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the OracleType.
    /// </summary>
    /// <value>
    /// The underlying rows OracleType cell
    /// </value>
    public virtual System.String OracleType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("OracleType") ? null : (System.String) row["OracleType"]; 
        else
          return row.IsNull(row.Table.Columns["OracleType"], DataRowVersion.Original) ? null : (System.String) row["OracleType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["OracleType"] = value; 
 
      } 
    }
    private ORMBiz.ParamCollection _Params = null;
  
    /// <summary>
    /// Refreshes the collection of Params from the underlying dataset
    /// </summary>
    internal void refreshParams()
    {
      if (_Params == null) _Params = new ORMBiz.ParamCollection();
      
      ((IList)_Params).Clear();

      DataRow[] cr = row.GetChildRows("FKDataTypeIDParam");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Param obj = new ORMBiz.Param(base.DataContext, chld);
        _Params.Add( obj );
      }
      
      // add after, so that events wont be fired
      _Params.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Params.
    /// </summary>
    public virtual ORMBiz.ParamCollection Params
    {
      get 
      { 
        if (_Params == null) refreshParams();

        return _Params;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Param to the collection.
      /// </summary>
      public virtual int AddParam(ORMBiz.Param newParam)
      {
        if ( _Params == null ) refreshParams();

        if ( newParam.row.GetParentRow(base.DataSet.Relations["FKDataTypeIDParam"]) == row )
          return _Params.IndexOf( newParam );

        newParam.row.SetParentRow(row,base.DataSet.Relations["FKDataTypeIDParam"]);

        int index = _Params.Add( newParam );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Param, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new Param object</returns>
      public virtual ORMBiz.Param NewParam()
      {
        if ( _Params == null ) refreshParams();

        ORMBiz.Param newParam = new ORMBiz.Param(base.DataContext, base.DataSet.Tables["Param"].NewRow());
        base.DataSet.Tables["Param"].Rows.Add(newParam.row);
        
        this.AddParam(newParam);

        return newParam;
      }
  
    private ORMBiz.ColumnCollection _Columns = null;
  
    /// <summary>
    /// Refreshes the collection of Columns from the underlying dataset
    /// </summary>
    internal void refreshColumns()
    {
      if (_Columns == null) _Columns = new ORMBiz.ColumnCollection();
      
      ((IList)_Columns).Clear();

      DataRow[] cr = row.GetChildRows("FKDataTypeIDColumn");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Column obj = new ORMBiz.Column(base.DataContext, chld);
        _Columns.Add( obj );
      }
      
      // add after, so that events wont be fired
      _Columns.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Columns.
    /// </summary>
    public virtual ORMBiz.ColumnCollection Columns
    {
      get 
      { 
        if (_Columns == null) refreshColumns();

        return _Columns;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Column to the collection.
      /// </summary>
      public virtual int AddColumn(ORMBiz.Column newColumn)
      {
        if ( _Columns == null ) refreshColumns();

        if ( newColumn.row.GetParentRow(base.DataSet.Relations["FKDataTypeIDColumn"]) == row )
          return _Columns.IndexOf( newColumn );

        newColumn.row.SetParentRow(row,base.DataSet.Relations["FKDataTypeIDColumn"]);

        int index = _Columns.Add( newColumn );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Column, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new Column object</returns>
      public virtual ORMBiz.Column NewColumn()
      {
        if ( _Columns == null ) refreshColumns();

        ORMBiz.Column newColumn = new ORMBiz.Column(base.DataContext, base.DataSet.Tables["Column"].NewRow());
        base.DataSet.Tables["Column"].Rows.Add(newColumn.row);
        
        this.AddColumn(newColumn);

        return newColumn;
      }
  

  }



  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class ParamOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal ParamOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the FKProcedureID.
    /// </summary>
    /// <value>
    /// The underlying rows FKProcedureID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKProcedureID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKProcedureID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKProcedureID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKProcedureID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKProcedureID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKProcedureID"] = DBNull.Value;
        else
          row["FKProcedureID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the Name.
    /// </summary>
    /// <value>
    /// The underlying rows Name cell
    /// </value>
    public virtual System.String Name 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("Name") ? null : (System.String) row["Name"]; 
        else
          return row.IsNull(row.Table.Columns["Name"], DataRowVersion.Original) ? null : (System.String) row["Name", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["Name"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the FKDataTypeID.
    /// </summary>
    /// <value>
    /// The underlying rows FKDataTypeID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKDataTypeID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKDataTypeID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDataTypeID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKDataTypeID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDataTypeID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKDataTypeID"] = DBNull.Value;
        else
          row["FKDataTypeID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the Length.
    /// </summary>
    /// <value>
    /// The underlying rows Length cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 Length 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("Length"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["Length"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["Length"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["Length", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["Length"] = DBNull.Value;
        else
          row["Length"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the IsOutputParam.
    /// </summary>
    /// <value>
    /// The underlying rows IsOutputParam cell
    /// </value>
    public virtual System.String IsOutputParam 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("IsOutputParam") ? null : (System.String) row["IsOutputParam"]; 
        else
          return row.IsNull(row.Table.Columns["IsOutputParam"], DataRowVersion.Original) ? null : (System.String) row["IsOutputParam", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["IsOutputParam"] = value; 
 
      } 
    }
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.Procedure.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.Procedure Procedure
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKProcedureIDParam"]) != null)
          return new ORMBiz.Procedure( DataContext, row.GetParentRow("FKProcedureIDParam"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKProcedureIDParam"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKProcedureIDParam"] );      
      }
    }
  
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.DataType.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.DataType DataType
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKDataTypeIDParam"]) != null)
          return new ORMBiz.DataType( DataContext, row.GetParentRow("FKDataTypeIDParam"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKDataTypeIDParam"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKDataTypeIDParam"] );      
      }
    }
  

  }



  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class ProcedureOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal ProcedureOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the Name.
    /// </summary>
    /// <value>
    /// The underlying rows Name cell
    /// </value>
    public virtual System.String Name 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("Name") ? null : (System.String) row["Name"]; 
        else
          return row.IsNull(row.Table.Columns["Name"], DataRowVersion.Original) ? null : (System.String) row["Name", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["Name"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the FKDatabaseID.
    /// </summary>
    /// <value>
    /// The underlying rows FKDatabaseID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKDatabaseID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKDatabaseID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDatabaseID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKDatabaseID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDatabaseID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKDatabaseID"] = DBNull.Value;
        else
          row["FKDatabaseID"] = value.Value; 
 
      } 
    }
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.Database.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.Database Database
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKDatabaseIDProcedure"]) != null)
          return new ORMBiz.Database( DataContext, row.GetParentRow("FKDatabaseIDProcedure"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKDatabaseIDProcedure"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKDatabaseIDProcedure"] );      
      }
    }
  
    private ORMBiz.ParamCollection _Params = null;
  
    /// <summary>
    /// Refreshes the collection of Params from the underlying dataset
    /// </summary>
    internal void refreshParams()
    {
      if (_Params == null) _Params = new ORMBiz.ParamCollection();
      
      ((IList)_Params).Clear();

      DataRow[] cr = row.GetChildRows("FKProcedureIDParam");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Param obj = new ORMBiz.Param(base.DataContext, chld);
        _Params.Add( obj );
      }
      
      // add after, so that events wont be fired
      _Params.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Params.
    /// </summary>
    public virtual ORMBiz.ParamCollection Params
    {
      get 
      { 
        if (_Params == null) refreshParams();

        return _Params;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Param to the collection.
      /// </summary>
      public virtual int AddParam(ORMBiz.Param newParam)
      {
        if ( _Params == null ) refreshParams();

        if ( newParam.row.GetParentRow(base.DataSet.Relations["FKProcedureIDParam"]) == row )
          return _Params.IndexOf( newParam );

        newParam.row.SetParentRow(row,base.DataSet.Relations["FKProcedureIDParam"]);

        int index = _Params.Add( newParam );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Param, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new Param object</returns>
      public virtual ORMBiz.Param NewParam()
      {
        if ( _Params == null ) refreshParams();

        ORMBiz.Param newParam = new ORMBiz.Param(base.DataContext, base.DataSet.Tables["Param"].NewRow());
        base.DataSet.Tables["Param"].Rows.Add(newParam.row);
        
        this.AddParam(newParam);

        return newParam;
      }
  

  }



  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class RelationOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal RelationOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the FKParentTableID.
    /// </summary>
    /// <value>
    /// The underlying rows FKParentTableID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKParentTableID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKParentTableID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKParentTableID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKParentTableID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKParentTableID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKParentTableID"] = DBNull.Value;
        else
          row["FKParentTableID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the FKChildTableID.
    /// </summary>
    /// <value>
    /// The underlying rows FKChildTableID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKChildTableID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKChildTableID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKChildTableID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKChildTableID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKChildTableID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKChildTableID"] = DBNull.Value;
        else
          row["FKChildTableID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ForeignKeyColumnName.
    /// </summary>
    /// <value>
    /// The underlying rows ForeignKeyColumnName cell
    /// </value>
    public virtual System.String ForeignKeyColumnName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ForeignKeyColumnName") ? null : (System.String) row["ForeignKeyColumnName"]; 
        else
          return row.IsNull(row.Table.Columns["ForeignKeyColumnName"], DataRowVersion.Original) ? null : (System.String) row["ForeignKeyColumnName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ForeignKeyColumnName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the RelationshipType.
    /// </summary>
    /// <value>
    /// The underlying rows RelationshipType cell
    /// </value>
    public virtual System.String RelationshipType 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("RelationshipType") ? null : (System.String) row["RelationshipType"]; 
        else
          return row.IsNull(row.Table.Columns["RelationshipType"], DataRowVersion.Original) ? null : (System.String) row["RelationshipType", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["RelationshipType"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ChildAccessorName.
    /// </summary>
    /// <value>
    /// The underlying rows ChildAccessorName cell
    /// </value>
    public virtual System.String ChildAccessorName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ChildAccessorName") ? null : (System.String) row["ChildAccessorName"]; 
        else
          return row.IsNull(row.Table.Columns["ChildAccessorName"], DataRowVersion.Original) ? null : (System.String) row["ChildAccessorName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ChildAccessorName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ParentAccessorName.
    /// </summary>
    /// <value>
    /// The underlying rows ParentAccessorName cell
    /// </value>
    public virtual System.String ParentAccessorName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ParentAccessorName") ? null : (System.String) row["ParentAccessorName"]; 
        else
          return row.IsNull(row.Table.Columns["ParentAccessorName"], DataRowVersion.Original) ? null : (System.String) row["ParentAccessorName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ParentAccessorName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ChildSetAccessor.
    /// </summary>
    /// <value>
    /// The underlying rows ChildSetAccessor cell
    /// </value>
    public virtual System.String ChildSetAccessor 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ChildSetAccessor") ? null : (System.String) row["ChildSetAccessor"]; 
        else
          return row.IsNull(row.Table.Columns["ChildSetAccessor"], DataRowVersion.Original) ? null : (System.String) row["ChildSetAccessor", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ChildSetAccessor"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ChildGetAccessor.
    /// </summary>
    /// <value>
    /// The underlying rows ChildGetAccessor cell
    /// </value>
    public virtual System.String ChildGetAccessor 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ChildGetAccessor") ? null : (System.String) row["ChildGetAccessor"]; 
        else
          return row.IsNull(row.Table.Columns["ChildGetAccessor"], DataRowVersion.Original) ? null : (System.String) row["ChildGetAccessor", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ChildGetAccessor"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ParentSetAccessor.
    /// </summary>
    /// <value>
    /// The underlying rows ParentSetAccessor cell
    /// </value>
    public virtual System.String ParentSetAccessor 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ParentSetAccessor") ? null : (System.String) row["ParentSetAccessor"]; 
        else
          return row.IsNull(row.Table.Columns["ParentSetAccessor"], DataRowVersion.Original) ? null : (System.String) row["ParentSetAccessor", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ParentSetAccessor"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ParentGetAccessor.
    /// </summary>
    /// <value>
    /// The underlying rows ParentGetAccessor cell
    /// </value>
    public virtual System.String ParentGetAccessor 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ParentGetAccessor") ? null : (System.String) row["ParentGetAccessor"]; 
        else
          return row.IsNull(row.Table.Columns["ParentGetAccessor"], DataRowVersion.Original) ? null : (System.String) row["ParentGetAccessor", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ParentGetAccessor"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the IsMandatory.
    /// </summary>
    /// <value>
    /// The underlying rows IsMandatory cell
    /// </value>
    public virtual System.String IsMandatory 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("IsMandatory") ? null : (System.String) row["IsMandatory"]; 
        else
          return row.IsNull(row.Table.Columns["IsMandatory"], DataRowVersion.Original) ? null : (System.String) row["IsMandatory", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["IsMandatory"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the DisassociateChild.
    /// </summary>
    /// <value>
    /// The underlying rows DisassociateChild cell
    /// </value>
    public virtual System.String DisassociateChild 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("DisassociateChild") ? null : (System.String) row["DisassociateChild"]; 
        else
          return row.IsNull(row.Table.Columns["DisassociateChild"], DataRowVersion.Original) ? null : (System.String) row["DisassociateChild", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["DisassociateChild"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the CascadeDelete.
    /// </summary>
    /// <value>
    /// The underlying rows CascadeDelete cell
    /// </value>
    public virtual System.String CascadeDelete 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("CascadeDelete") ? null : (System.String) row["CascadeDelete"]; 
        else
          return row.IsNull(row.Table.Columns["CascadeDelete"], DataRowVersion.Original) ? null : (System.String) row["CascadeDelete", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["CascadeDelete"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the CascadeUpdate.
    /// </summary>
    /// <value>
    /// The underlying rows CascadeUpdate cell
    /// </value>
    public virtual System.String CascadeUpdate 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("CascadeUpdate") ? null : (System.String) row["CascadeUpdate"]; 
        else
          return row.IsNull(row.Table.Columns["CascadeUpdate"], DataRowVersion.Original) ? null : (System.String) row["CascadeUpdate", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["CascadeUpdate"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the EnforceConstraint.
    /// </summary>
    /// <value>
    /// The underlying rows EnforceConstraint cell
    /// </value>
    public virtual System.String EnforceConstraint 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("EnforceConstraint") ? null : (System.String) row["EnforceConstraint"]; 
        else
          return row.IsNull(row.Table.Columns["EnforceConstraint"], DataRowVersion.Original) ? null : (System.String) row["EnforceConstraint", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["EnforceConstraint"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the NullableFKey.
    /// </summary>
    /// <value>
    /// The underlying rows NullableFKey cell
    /// </value>
    public virtual System.String NullableFKey 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("NullableFKey") ? null : (System.String) row["NullableFKey"]; 
        else
          return row.IsNull(row.Table.Columns["NullableFKey"], DataRowVersion.Original) ? null : (System.String) row["NullableFKey", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["NullableFKey"] = value; 
 
      } 
    }
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.Table.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.Table ParentTable
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKParentTableIDRelation"]) != null)
          return new ORMBiz.Table( DataContext, row.GetParentRow("FKParentTableIDRelation"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKParentTableIDRelation"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKParentTableIDRelation"] );      
      }
    }
  
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.Table.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.Table ChildTable
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKChildTableIDRelation"]) != null)
          return new ORMBiz.Table( DataContext, row.GetParentRow("FKChildTableIDRelation"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKChildTableIDRelation"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKChildTableIDRelation"] );      
      }
    }
  
    private ORMBiz.RelationColumnCollection _RelationColumns = null;
  
    /// <summary>
    /// Refreshes the collection of RelationColumns from the underlying dataset
    /// </summary>
    internal void refreshRelationColumns()
    {
      if (_RelationColumns == null) _RelationColumns = new ORMBiz.RelationColumnCollection();
      
      ((IList)_RelationColumns).Clear();

      DataRow[] cr = row.GetChildRows("FKRelationIDRelationColumn");
      foreach( DataRow chld in cr)
      {
        ORMBiz.RelationColumn obj = new ORMBiz.RelationColumn(base.DataContext, chld);
        _RelationColumns.Add( obj );
      }
      
      // add after, so that events wont be fired
      _RelationColumns.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.RelationColumns.
    /// </summary>
    public virtual ORMBiz.RelationColumnCollection RelationColumns
    {
      get 
      { 
        if (_RelationColumns == null) refreshRelationColumns();

        return _RelationColumns;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.RelationColumn to the collection.
      /// </summary>
      public virtual int AddRelationColumn(ORMBiz.RelationColumn newRelationColumn)
      {
        if ( _RelationColumns == null ) refreshRelationColumns();

        if ( newRelationColumn.row.GetParentRow(base.DataSet.Relations["FKRelationIDRelationColumn"]) == row )
          return _RelationColumns.IndexOf( newRelationColumn );

        newRelationColumn.row.SetParentRow(row,base.DataSet.Relations["FKRelationIDRelationColumn"]);

        int index = _RelationColumns.Add( newRelationColumn );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.RelationColumn, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new RelationColumn object</returns>
      public virtual ORMBiz.RelationColumn NewRelationColumn()
      {
        if ( _RelationColumns == null ) refreshRelationColumns();

        ORMBiz.RelationColumn newRelationColumn = new ORMBiz.RelationColumn(base.DataContext, base.DataSet.Tables["RelationColumn"].NewRow());
        base.DataSet.Tables["RelationColumn"].Rows.Add(newRelationColumn.row);
        
        this.AddRelationColumn(newRelationColumn);

        return newRelationColumn;
      }
  

  }



  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class RelationColumnOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal RelationColumnOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the FKRelationID.
    /// </summary>
    /// <value>
    /// The underlying rows FKRelationID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKRelationID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKRelationID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKRelationID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKRelationID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKRelationID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKRelationID"] = DBNull.Value;
        else
          row["FKRelationID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ParentColumnName.
    /// </summary>
    /// <value>
    /// The underlying rows ParentColumnName cell
    /// </value>
    public virtual System.String ParentColumnName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ParentColumnName") ? null : (System.String) row["ParentColumnName"]; 
        else
          return row.IsNull(row.Table.Columns["ParentColumnName"], DataRowVersion.Original) ? null : (System.String) row["ParentColumnName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ParentColumnName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ChildColumnName.
    /// </summary>
    /// <value>
    /// The underlying rows ChildColumnName cell
    /// </value>
    public virtual System.String ChildColumnName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ChildColumnName") ? null : (System.String) row["ChildColumnName"]; 
        else
          return row.IsNull(row.Table.Columns["ChildColumnName"], DataRowVersion.Original) ? null : (System.String) row["ChildColumnName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ChildColumnName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the OrdinalPosition.
    /// </summary>
    /// <value>
    /// The underlying rows OrdinalPosition cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 OrdinalPosition 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("OrdinalPosition"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["OrdinalPosition"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["OrdinalPosition"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["OrdinalPosition", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["OrdinalPosition"] = DBNull.Value;
        else
          row["OrdinalPosition"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the NullableFKey.
    /// </summary>
    /// <value>
    /// The underlying rows NullableFKey cell
    /// </value>
    public virtual System.String NullableFKey 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("NullableFKey") ? null : (System.String) row["NullableFKey"]; 
        else
          return row.IsNull(row.Table.Columns["NullableFKey"], DataRowVersion.Original) ? null : (System.String) row["NullableFKey", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["NullableFKey"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the ChildColumnIsPrimaryKey.
    /// </summary>
    /// <value>
    /// The underlying rows ChildColumnIsPrimaryKey cell
    /// </value>
    public virtual System.String ChildColumnIsPrimaryKey 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("ChildColumnIsPrimaryKey") ? null : (System.String) row["ChildColumnIsPrimaryKey"]; 
        else
          return row.IsNull(row.Table.Columns["ChildColumnIsPrimaryKey"], DataRowVersion.Original) ? null : (System.String) row["ChildColumnIsPrimaryKey", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["ChildColumnIsPrimaryKey"] = value; 
 
      } 
    }
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.Relation.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.Relation Relation
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKRelationIDRelationColumn"]) != null)
          return new ORMBiz.Relation( DataContext, row.GetParentRow("FKRelationIDRelationColumn"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKRelationIDRelationColumn"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKRelationIDRelationColumn"] );      
      }
    }
  

  }



  /// <summary>
  /// Wraps a datarow, exposing it's richest features as properties and methods.
  /// </summary>
  public abstract class TableOrmTemplate : Business
  {
    /// <summary>
    /// Default Constructor
    /// </summary>
    /// <param name="dataContext">The DataManager this object should perform it's operations with</param>
    /// <param name="ROW">The underlying row that this object will wrap</param>
    internal TableOrmTemplate( DataManager dataContext, DataRow ROW) : base(dataContext) 
    { 
      row = ROW; 
    }


    /// <summary>
    /// Gets and sets the property at the underlying row index.
    /// </summary>
    public object this[int index]
    {
      get
      {
        if ( this.row.IsNull(index) )
          return null;
        else
          return this.row[index];
      }
      set
      {
        if ( value == null )
          this.row[index] = DBNull.Value;
        else
          this.row[index] = value;
      }
    }

    /// <summary>
    /// Gets and sets the property by its name.
    /// </summary>
    /// <remarks>
    /// Do not use the underlying column name if it is different.
    /// </remarks>
    public object this[string property]
    {
      get
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanRead )
          return pi.GetValue(this, null);

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Get" + property,new Type[]{});
                
        if ( mi != null )
          return mi.Invoke(this, null);

        return null;
      }
      set
      {
        System.Reflection.PropertyInfo pi = this.GetType().GetProperty(property);
        
        if ( pi != null && pi.CanWrite )
        {
          pi.SetValue(this, value, null);
          return;
        }

        System.Reflection.MethodInfo mi = this.GetType().GetMethod("Set" + property,new Type[]{value.GetType()});
                
        if ( mi != null )
          mi.Invoke(this, new object[]{value});
      }
    }    

    
    /// <summary>
    /// Returns true if the underlying DataRow.RowState is marked as DataRowState.Deleted
    /// </summary>
    /// <returns>true if deleted</returns>
    public virtual bool IsDeleted()
    {
      return row.RowState == DataRowState.Deleted;
    }

    /// <summary>
    /// Gets the ID.
    /// </summary>
    /// <value>
    /// The underlying rows ID cell
    /// </value>
    public virtual System.Int32 ID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return (System.Int32) row["ID"]; 
        else
          return (System.Int32) row["ID", DataRowVersion.Original];
        
        //System.Int32 
      } 
    } 
    /// <summary>
    /// Gets and Sets the FKDatabaseID.
    /// </summary>
    /// <value>
    /// The underlying rows FKDatabaseID cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 FKDatabaseID 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("FKDatabaseID"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDatabaseID"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["FKDatabaseID"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["FKDatabaseID", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["FKDatabaseID"] = DBNull.Value;
        else
          row["FKDatabaseID"] = value.Value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the Name.
    /// </summary>
    /// <value>
    /// The underlying rows Name cell
    /// </value>
    public virtual System.String Name 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("Name") ? null : (System.String) row["Name"]; 
        else
          return row.IsNull(row.Table.Columns["Name"], DataRowVersion.Original) ? null : (System.String) row["Name", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["Name"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the AllowNew.
    /// </summary>
    /// <value>
    /// The underlying rows AllowNew cell
    /// </value>
    public virtual System.String AllowNew 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("AllowNew") ? null : (System.String) row["AllowNew"]; 
        else
          return row.IsNull(row.Table.Columns["AllowNew"], DataRowVersion.Original) ? null : (System.String) row["AllowNew", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["AllowNew"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the IsLookupTable.
    /// </summary>
    /// <value>
    /// The underlying rows IsLookupTable cell
    /// </value>
    public virtual System.String IsLookupTable 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("IsLookupTable") ? null : (System.String) row["IsLookupTable"]; 
        else
          return row.IsNull(row.Table.Columns["IsLookupTable"], DataRowVersion.Original) ? null : (System.String) row["IsLookupTable", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["IsLookupTable"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the GenerateCodeFor.
    /// </summary>
    /// <value>
    /// The underlying rows GenerateCodeFor cell
    /// </value>
    public virtual System.String GenerateCodeFor 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("GenerateCodeFor") ? null : (System.String) row["GenerateCodeFor"]; 
        else
          return row.IsNull(row.Table.Columns["GenerateCodeFor"], DataRowVersion.Original) ? null : (System.String) row["GenerateCodeFor", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["GenerateCodeFor"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the AccessorName.
    /// </summary>
    /// <value>
    /// The underlying rows AccessorName cell
    /// </value>
    public virtual System.String AccessorName 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("AccessorName") ? null : (System.String) row["AccessorName"]; 
        else
          return row.IsNull(row.Table.Columns["AccessorName"], DataRowVersion.Original) ? null : (System.String) row["AccessorName", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["AccessorName"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the GenerateSampleCode.
    /// </summary>
    /// <value>
    /// The underlying rows GenerateSampleCode cell
    /// </value>
    public virtual System.String GenerateSampleCode 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
          return row.IsNull("GenerateSampleCode") ? null : (System.String) row["GenerateSampleCode"]; 
        else
          return row.IsNull(row.Table.Columns["GenerateSampleCode"], DataRowVersion.Original) ? null : (System.String) row["GenerateSampleCode", DataRowVersion.Original]; 

        //System.String 
      } 
      set
      { 
        row["GenerateSampleCode"] = value; 
 
      } 
    }
    /// <summary>
    /// Gets and Sets the InsertOrder.
    /// </summary>
    /// <value>
    /// The underlying rows InsertOrder cell
    /// </value>
    public virtual System.Data.SqlTypes.SqlInt32 InsertOrder 
    { 
      get
      { 
        if (row.RowState != DataRowState.Deleted)
        {
          if (row.IsNull("InsertOrder"))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["InsertOrder"]);
        }
        else
        {
          if (row.IsNull(row.Table.Columns["InsertOrder"], DataRowVersion.Original))
            return System.Data.SqlTypes.SqlInt32.Null;
          else
            return new System.Data.SqlTypes.SqlInt32((System.Int32)row["InsertOrder", DataRowVersion.Original]);
        }
 
      } 
      set
      { 
        if ( value.IsNull ) 
          row["InsertOrder"] = DBNull.Value;
        else
          row["InsertOrder"] = value.Value; 
 
      } 
    }
    
    /// <summary>
    /// Gets and Sets the parent ORMBiz.Database.
    /// </summary>
    [System.ComponentModel.Bindable(false)] 
    public virtual ORMBiz.Database Database
    {
      get
      {
        if (row.GetParentRow(base.DataSet.Relations["FKDatabaseIDTable"]) != null)
          return new ORMBiz.Database( DataContext, row.GetParentRow("FKDatabaseIDTable"));
        else
          return null;
      }
      set
      {
        if ( value == null )
        {
          row.SetParentRow(null, base.DataSet.Relations["FKDatabaseIDTable"] );
        }
        else
          row.SetParentRow( value.row, base.DataSet.Relations["FKDatabaseIDTable"] );      
      }
    }
  
    private ORMBiz.ColumnCollection _Columns = null;
  
    /// <summary>
    /// Refreshes the collection of Columns from the underlying dataset
    /// </summary>
    internal void refreshColumns()
    {
      if (_Columns == null) _Columns = new ORMBiz.ColumnCollection();
      
      ((IList)_Columns).Clear();

      DataRow[] cr = row.GetChildRows("FKTableIDColumn");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Column obj = new ORMBiz.Column(base.DataContext, chld);
        _Columns.Add( obj );
      }
      
      // add after, so that events wont be fired
      _Columns.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Columns.
    /// </summary>
    public virtual ORMBiz.ColumnCollection Columns
    {
      get 
      { 
        if (_Columns == null) refreshColumns();

        return _Columns;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Column to the collection.
      /// </summary>
      public virtual int AddColumn(ORMBiz.Column newColumn)
      {
        if ( _Columns == null ) refreshColumns();

        if ( newColumn.row.GetParentRow(base.DataSet.Relations["FKTableIDColumn"]) == row )
          return _Columns.IndexOf( newColumn );

        newColumn.row.SetParentRow(row,base.DataSet.Relations["FKTableIDColumn"]);

        int index = _Columns.Add( newColumn );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Column, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new Column object</returns>
      public virtual ORMBiz.Column NewColumn()
      {
        if ( _Columns == null ) refreshColumns();

        ORMBiz.Column newColumn = new ORMBiz.Column(base.DataContext, base.DataSet.Tables["Column"].NewRow());
        base.DataSet.Tables["Column"].Rows.Add(newColumn.row);
        
        this.AddColumn(newColumn);

        return newColumn;
      }
  
    private ORMBiz.RelationCollection _ChildRelations = null;
  
    /// <summary>
    /// Refreshes the collection of ChildRelations from the underlying dataset
    /// </summary>
    internal void refreshChildRelations()
    {
      if (_ChildRelations == null) _ChildRelations = new ORMBiz.RelationCollection();
      
      ((IList)_ChildRelations).Clear();

      DataRow[] cr = row.GetChildRows("FKParentTableIDRelation");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Relation obj = new ORMBiz.Relation(base.DataContext, chld);
        _ChildRelations.Add( obj );
      }
      
      // add after, so that events wont be fired
      _ChildRelations.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Relations.
    /// </summary>
    public virtual ORMBiz.RelationCollection ChildRelations
    {
      get 
      { 
        if (_ChildRelations == null) refreshChildRelations();

        return _ChildRelations;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Relation to the collection.
      /// </summary>
      public virtual int AddChildRelation(ORMBiz.Relation newChildRelation)
      {
        if ( _ChildRelations == null ) refreshChildRelations();

        if ( newChildRelation.row.GetParentRow(base.DataSet.Relations["FKParentTableIDRelation"]) == row )
          return _ChildRelations.IndexOf( newChildRelation );

        newChildRelation.row.SetParentRow(row,base.DataSet.Relations["FKParentTableIDRelation"]);

        int index = _ChildRelations.Add( newChildRelation );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Relation, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new ChildRelation object</returns>
      public virtual ORMBiz.Relation NewChildRelation()
      {
        if ( _ChildRelations == null ) refreshChildRelations();

        ORMBiz.Relation newChildRelation = new ORMBiz.Relation(base.DataContext, base.DataSet.Tables["Relation"].NewRow());
        base.DataSet.Tables["Relation"].Rows.Add(newChildRelation.row);
        
        this.AddChildRelation(newChildRelation);

        return newChildRelation;
      }
  
    private ORMBiz.RelationCollection _ParentRelations = null;
  
    /// <summary>
    /// Refreshes the collection of ParentRelations from the underlying dataset
    /// </summary>
    internal void refreshParentRelations()
    {
      if (_ParentRelations == null) _ParentRelations = new ORMBiz.RelationCollection();
      
      ((IList)_ParentRelations).Clear();

      DataRow[] cr = row.GetChildRows("FKChildTableIDRelation");
      foreach( DataRow chld in cr)
      {
        ORMBiz.Relation obj = new ORMBiz.Relation(base.DataContext, chld);
        _ParentRelations.Add( obj );
      }
      
      // add after, so that events wont be fired
      _ParentRelations.Parent = this;
    }
        
    /// <summary>
    /// Exposes the collection of child ORMBiz.Relations.
    /// </summary>
    public virtual ORMBiz.RelationCollection ParentRelations
    {
      get 
      { 
        if (_ParentRelations == null) refreshParentRelations();

        return _ParentRelations;
      }
    }


      /// <summary>
      /// Adds a ORMBiz.Relation to the collection.
      /// </summary>
      public virtual int AddParentRelation(ORMBiz.Relation newParentRelation)
      {
        if ( _ParentRelations == null ) refreshParentRelations();

        if ( newParentRelation.row.GetParentRow(base.DataSet.Relations["FKChildTableIDRelation"]) == row )
          return _ParentRelations.IndexOf( newParentRelation );

        newParentRelation.row.SetParentRow(row,base.DataSet.Relations["FKChildTableIDRelation"]);

        int index = _ParentRelations.Add( newParentRelation );

        return index;

      }

      /// <summary>
      /// Creates a new ORMBiz.Relation, adding it to the collection.
      /// </summary>
      /// <remarks>
      /// CommitAll() must be called to persist this to the database.
      /// </remarks>
      /// <returns>A new ParentRelation object</returns>
      public virtual ORMBiz.Relation NewParentRelation()
      {
        if ( _ParentRelations == null ) refreshParentRelations();

        ORMBiz.Relation newParentRelation = new ORMBiz.Relation(base.DataContext, base.DataSet.Tables["Relation"].NewRow());
        base.DataSet.Tables["Relation"].Rows.Add(newParentRelation.row);
        
        this.AddParentRelation(newParentRelation);

        return newParentRelation;
      }
  

  }


}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.