csharp/CslaGenFork/CslaGenFork/tags/DeepLoad%20sample%20v.1.0.0/ParentLoad.Business/ERCLevel/B05Level111Child.Designer.cs

B05Level111Child.Designer.cs
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;

namespace ParentLoad.Business.ERCLevel
{

    /// 
    /// B05Level111Child (editable child object).
    /// This is a generated base clast of  business object.
    /// 
    /// 
    /// This clast is an item of  collection.
    /// 
    [Serializable]
    public partial clast B05Level111Child : BusinessBase
    {

        #region State Fields

        [NotUndoable]
        [NonSerialized]
        internal int cMarentID1 = 0;

        #endregion

        #region Business Properties

        /// 
        /// Maintains metadata about  property.
        /// 
        public static readonly PropertyInfo Level_1_1_1_Child_NameProperty = RegisterProperty(p => p.Level_1_1_1_Child_Name, "Level_1_1_1 Child Name");
        /// 
        /// Gets or sets the Level_1_1_1 Child Name.
        /// 
        /// The Level_1_1_1 Child Name.
        public string Level_1_1_1_Child_Name
        {
            get { return GetProperty(Level_1_1_1_Child_NameProperty); }
            set { SetProperty(Level_1_1_1_Child_NameProperty, value); }
        }

        #endregion

        #region Factory Methods

        /// 
        /// Factory method. Creates a new  object.
        /// 
        /// A reference to the created  object.
        internal static B05Level111Child NewB05Level111Child()
        {
            return DataPortal.CreateChild();
        }

        /// 
        /// Factory method. Loads a  object from the given SafeDataReader.
        /// 
        /// The SafeDataReader to use.
        /// A reference to the fetched  object.
        internal static B05Level111Child GetB05Level111Child(SafeDataReader dr)
        {
            B05Level111Child obj = new B05Level111Child();
            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(dr);
            obj.MarkOld();
            return obj;
        }

        #endregion

        #region Constructor

        /// 
        /// Initializes a new instance of the  clast.
        /// 
        ///  Do not use to create a Csla object. Use factory methods instead.
        private B05Level111Child()
        {
            // Prevent direct creation

            // show the framework that this is a child object
            MarkAsChild();
        }

        #endregion

        #region Data Access

        /// 
        /// Loads default values for the  object properties.
        /// 
        [Csla.RunLocal]
        protected override void Child_Create()
        {
            var args = new DataPortalHookArgs();
            OnCreate(args);
            base.Child_Create();
        }

        /// 
        /// Loads a  object from the given SafeDataReader.
        /// 
        /// The SafeDataReader to use.
        private void Fetch(SafeDataReader dr)
        {
            // Value properties
            LoadProperty(Level_1_1_1_Child_NameProperty, dr.GetString("Level_1_1_1_Child_Name"));
            cMarentID1 = dr.GetInt32("CMarentID1");
            var args = new DataPortalHookArgs(dr);
            OnFetchRead(args);
        }

        /// 
        /// Inserts a new  object in the database.
        /// 
        /// The parent object.
        [Transactional(TransactionalTypes.TransactionScope)]
        private void Child_Insert(B04Level11 parent)
        {
            using (var ctx = ConnectionManager.GetManager("DeepLoad"))
            {
                using (var cmd = new SqlCommand("AddB05Level111Child", ctx.Connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Level_1_1_ID", parent.Level_1_1_ID).DbType = DbType.Int32;
                    cmd.Parameters.AddWithValue("@Level_1_1_1_Child_Name", ReadProperty(Level_1_1_1_Child_NameProperty)).DbType = DbType.String;
                    var args = new DataPortalHookArgs(cmd);
                    OnInsertPre(args);
                    cmd.ExecuteNonQuery();
                    OnInsertPost(args);
                }
            }
        }

        /// 
        /// Updates in the database all changes made to the  object.
        /// 
        /// The parent object.
        [Transactional(TransactionalTypes.TransactionScope)]
        private void Child_Update(B04Level11 parent)
        {
            using (var ctx = ConnectionManager.GetManager("DeepLoad"))
            {
                using (var cmd = new SqlCommand("UpdateB05Level111Child", ctx.Connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Level_1_1_ID", parent.Level_1_1_ID).DbType = DbType.Int32;
                    cmd.Parameters.AddWithValue("@Level_1_1_1_Child_Name", ReadProperty(Level_1_1_1_Child_NameProperty)).DbType = DbType.String;
                    var args = new DataPortalHookArgs(cmd);
                    OnUpdatePre(args);
                    cmd.ExecuteNonQuery();
                    OnUpdatePost(args);
                }
            }
        }

        /// 
        /// Self deletes the  object from database.
        /// 
        /// The parent object.
        [Transactional(TransactionalTypes.TransactionScope)]
        private void Child_DeleteSelf(B04Level11 parent)
        {
            using (var ctx = ConnectionManager.GetManager("DeepLoad"))
            {
                using (var cmd = new SqlCommand("DeleteB05Level111Child", ctx.Connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Level_1_1_ID", parent.Level_1_1_ID).DbType = DbType.Int32;
                    var args = new DataPortalHookArgs(cmd);
                    OnDeletePre(args);
                    cmd.ExecuteNonQuery();
                    OnDeletePost(args);
                }
            }
        }

        #endregion

        #region Pseudo Events

        /// 
        /// Occurs after setting all defaults for object creation.
        /// 
        partial void OnCreate(DataPortalHookArgs args);

        /// 
        /// Occurs in DataPortal_Delete, after setting query parameters and before the delete operation.
        /// 
        partial void OnDeletePre(DataPortalHookArgs args);

        /// 
        /// Occurs in DataPortal_Delete, after the delete operation, before Commit().
        /// 
        partial void OnDeletePost(DataPortalHookArgs args);

        /// 
        /// Occurs after setting query parameters and before the fetch operation.
        /// 
        partial void OnFetchPre(DataPortalHookArgs args);

        /// 
        /// Occurs after the fetch operation (object or collection is fully loaded and set up).
        /// 
        partial void OnFetchPost(DataPortalHookArgs args);

        /// 
        /// Occurs after the low level fetch operation, before the data reader is destroyed.
        /// 
        partial void OnFetchRead(DataPortalHookArgs args);

        /// 
        /// Occurs after setting query parameters and before the update operation.
        /// 
        partial void OnUpdatePre(DataPortalHookArgs args);

        /// 
        /// Occurs in DataPortal_Insert, after the update operation, before setting back row identifiers (RowVersion) and Commit().
        /// 
        partial void OnUpdatePost(DataPortalHookArgs args);

        /// 
        /// Occurs in DataPortal_Insert, after setting query parameters and before the insert operation.
        /// 
        partial void OnInsertPre(DataPortalHookArgs args);

        /// 
        /// Occurs in DataPortal_Insert, after the insert operation, before setting back row identifiers (ID and RowVersion) and Commit().
        /// 
        partial void OnInsertPost(DataPortalHookArgs args);

        #endregion

    }
}