📄 templates.cs
字号:
}
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"];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -