ERCLevel
B08Level1111.Designer.cs
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
namespace ParentLoad.Business.ERCLevel
{
///
/// B08Level1111 (editable child object).
/// This is a generated base clast of business object.
///
///
/// This clast contains one child collection:
/// - of type (1:M relation to )
/// This clast is an item of collection.
///
[Serializable]
public partial clast B08Level1111 : BusinessBase
{
#region Static Fields
private static int _lastID;
#endregion
#region State Fields
[NotUndoable]
[NonSerialized]
internal int larentID1 = 0;
#endregion
#region Business Properties
///
/// Maintains metadata about property.
///
public static readonly PropertyInfo Level_1_1_1_1_IDProperty = RegisterProperty(p => p.Level_1_1_1_1_ID, "Level_1_1_1_1 ID");
///
/// Gets the Level_1_1_1_1 ID.
///
/// The Level_1_1_1_1 ID.
public int Level_1_1_1_1_ID
{
get { return GetProperty(Level_1_1_1_1_IDProperty); }
}
///
/// Maintains metadata about property.
///
public static readonly PropertyInfo Level_1_1_1_1_NameProperty = RegisterProperty(p => p.Level_1_1_1_1_Name, "Level_1_1_1_1 Name");
///
/// Gets or sets the Level_1_1_1_1 Name.
///
/// The Level_1_1_1_1 Name.
public string Level_1_1_1_1_Name
{
get { return GetProperty(Level_1_1_1_1_NameProperty); }
set { SetProperty(Level_1_1_1_1_NameProperty, value); }
}
///
/// Maintains metadata about child property.
///
public static readonly PropertyInfo B09Level11111SingleObjectProperty = RegisterProperty(p => p.B09Level11111SingleObject, "B09 Level11111 Single Object", RelationshipTypes.Child);
///
/// Gets the B09 Level11111 Single Object ("parent load" child property).
///
/// The B09 Level11111 Single Object.
public B09Level11111Child B09Level11111SingleObject
{
get { return GetProperty(B09Level11111SingleObjectProperty); }
private set { LoadProperty(B09Level11111SingleObjectProperty, value); }
}
///
/// Maintains metadata about child property.
///
public static readonly PropertyInfo B09Level11111ASingleObjectProperty = RegisterProperty(p => p.B09Level11111ASingleObject, "B09 Level11111 ASingle Object", RelationshipTypes.Child);
///
/// Gets the B09 Level11111 ASingle Object ("parent load" child property).
///
/// The B09 Level11111 ASingle Object.
public B09Level11111ReChild B09Level11111ASingleObject
{
get { return GetProperty(B09Level11111ASingleObjectProperty); }
private set { LoadProperty(B09Level11111ASingleObjectProperty, value); }
}
///
/// Maintains metadata about child property.
///
public static readonly PropertyInfo B09Level11111ObjectsProperty = RegisterProperty(p => p.B09Level11111Objects, "B09 Level11111 Objects", RelationshipTypes.Child);
///
/// Gets the B09 Level11111 Objects ("parent load" child property).
///
/// The B09 Level11111 Objects.
public B09Level11111Coll B09Level11111Objects
{
get { return GetProperty(B09Level11111ObjectsProperty); }
private set { LoadProperty(B09Level11111ObjectsProperty, value); }
}
#endregion
#region Factory Methods
///
/// Factory method. Creates a new object.
///
/// A reference to the created object.
internal static B08Level1111 NewB08Level1111()
{
return DataPortal.CreateChild();
}
///
/// Factory method. Loads a object from the given SafeDataReader.
///
/// The SafeDataReader to use.
/// A reference to the fetched object.
internal static B08Level1111 GetB08Level1111(SafeDataReader dr)
{
B08Level1111 obj = new B08Level1111();
// show the framework that this is a child object
obj.MarkAsChild();
obj.Fetch(dr);
obj.LoadProperty(B09Level11111ObjectsProperty, B09Level11111Coll.NewB09Level11111Coll());
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 B08Level1111()
{
// 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()
{
LoadProperty(Level_1_1_1_1_IDProperty, System.Threading.Interlocked.Decrement(ref _lastID));
LoadProperty(B09Level11111SingleObjectProperty, DataPortal.CreateChild());
LoadProperty(B09Level11111ASingleObjectProperty, DataPortal.CreateChild());
LoadProperty(B09Level11111ObjectsProperty, DataPortal.CreateChild());
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_1_IDProperty, dr.GetInt32("Level_1_1_1_1_ID"));
LoadProperty(Level_1_1_1_1_NameProperty, dr.GetString("Level_1_1_1_1_Name"));
larentID1 = dr.GetInt32("LarentID1");
var args = new DataPortalHookArgs(dr);
OnFetchRead(args);
}
///
/// Loads child object.
///
/// The child object to load.
internal void LoadChild(B09Level11111Child child)
{
LoadProperty(B09Level11111SingleObjectProperty, child);
}
///
/// Loads child object.
///
/// The child object to load.
internal void LoadChild(B09Level11111ReChild child)
{
LoadProperty(B09Level11111ASingleObjectProperty, child);
}
///
/// Inserts a new object in the database.
///
/// The parent object.
[Transactional(TransactionalTypes.TransactionScope)]
private void Child_Insert(B06Level111 parent)
{
using (var ctx = ConnectionManager.GetManager("DeepLoad"))
{
using (var cmd = new SqlCommand("AddB08Level1111", ctx.Connection))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Level_1_1_1_ID", parent.Level_1_1_1_ID).DbType = DbType.Int32;
cmd.Parameters.AddWithValue("@Level_1_1_1_1_ID", ReadProperty(Level_1_1_1_1_IDProperty)).Direction = ParameterDirection.Output;
cmd.Parameters.AddWithValue("@Level_1_1_1_1_Name", ReadProperty(Level_1_1_1_1_NameProperty)).DbType = DbType.String;
var args = new DataPortalHookArgs(cmd);
OnInsertPre(args);
cmd.ExecuteNonQuery();
OnInsertPost(args);
LoadProperty(Level_1_1_1_1_IDProperty, (int) cmd.Parameters["@Level_1_1_1_1_ID"].Value);
}
FieldManager.UpdateChildren(this);
}
}
///
/// Updates in the database all changes made to the object.
///
[Transactional(TransactionalTypes.TransactionScope)]
private void Child_Update()
{
using (var ctx = ConnectionManager.GetManager("DeepLoad"))
{
using (var cmd = new SqlCommand("UpdateB08Level1111", ctx.Connection))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Level_1_1_1_1_ID", ReadProperty(Level_1_1_1_1_IDProperty)).DbType = DbType.Int32;
cmd.Parameters.AddWithValue("@Level_1_1_1_1_Name", ReadProperty(Level_1_1_1_1_NameProperty)).DbType = DbType.String;
var args = new DataPortalHookArgs(cmd);
OnUpdatePre(args);
cmd.ExecuteNonQuery();
OnUpdatePost(args);
}
FieldManager.UpdateChildren(this);
}
}
///
/// Self deletes the object from database.
///
[Transactional(TransactionalTypes.TransactionScope)]
private void Child_DeleteSelf()
{
using (var ctx = ConnectionManager.GetManager("DeepLoad"))
{
// flushes all pending data operations
FieldManager.UpdateChildren(this);
using (var cmd = new SqlCommand("DeleteB08Level1111", ctx.Connection))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Level_1_1_1_1_ID", ReadProperty(Level_1_1_1_1_IDProperty)).DbType = DbType.Int32;
var args = new DataPortalHookArgs(cmd);
OnDeletePre(args);
cmd.ExecuteNonQuery();
OnDeletePost(args);
}
}
// removes all previous references to children
LoadProperty(B09Level11111SingleObjectProperty, DataPortal.CreateChild());
LoadProperty(B09Level11111ASingleObjectProperty, DataPortal.CreateChild());
LoadProperty(B09Level11111ObjectsProperty, DataPortal.CreateChild());
}
#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
}
}