📄 datamanager.cs
字号:
/// <remarks>
/// This method is made available for when the dataset has been serialized
/// from session state or disk.
/// </remarks>
/// <example>
/// This example shows a reason to use this method.
/// <code>
/// /* first web page - save dataset and primary keys */
/// Session["DataSet"] = dm.DataSet;
/// Session["DataTypeID"] = _DataType.ID;
///
/// /* second web page - need to get currend contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _DataType = dm.GetContactFromDataSet((System.Int32)Session["DataTypeID"]);
/// </code>
/// </example>
/// <param name="ID">Primary key of the data row to retrieve.</param>
/// <returns>A DataType, or null if not found</returns>
public ORMBiz.DataType GetDataTypeFromDataSet(System.Int32 ID)
{
DataRow DataTypeRow = null;
foreach(DataRow dr in DataSet.Tables["DataType"].Rows)
{
if ( ((System.Int32)dr["ID"]).ToString() == ID.ToString() )
{
DataTypeRow = dr;
break;
}
}
if ( DataTypeRow == null) return null;
return new ORMBiz.DataType (this, DataTypeRow);
}
/// <summary>
/// Gets multiple DataTypes based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <returns>A collection of DataType objects</returns>
public ORMBiz.DataTypeCollection GetDataTypeCollection()
{
return GetDataTypeCollection(FetchPath.DataType);
}
/// <summary>
/// Gets multiple DataTypes based on the criteria specified by AddCriteria(..).
/// </summary>
/// <param name="relations">Specify which related tables should be fetched during this query</param>
/// <returns>A collection of DataType objects</returns>
public ORMBiz.DataTypeCollection GetDataTypeCollection(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet(CreateSql("DataType", relations), ds, false);
DataRow[] DataTypeList = GetRows(ds,"DataType");
if ( DataTypeList == null ) return null;
ORMBiz.DataTypeCollection a = new ORMBiz.DataTypeCollection();
foreach ( DataRow dr in DataTypeList )
a.Add(new ORMBiz.DataType( this, dr ));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Gets a collection of DataType from the already loaded records in this DataManager instance.
/// </summary>
/// <remarks>
/// This method is made available for when the dataset has been serialized
/// from session state or disk. This method will return all DataType loaded.
/// </remarks>
/// <example>
/// This example shows a reason to use this method.
/// <code>
/// /* first web page - save dataset and primary keys */
/// Session["DataSet"] = dm.DataSet;
/// Session["DataTypeID"] = _DataType.ID;
///
/// /* second web page - need to get current contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _DataType = dm.GetContactFromDataSet((int)Session["DataTypeID"]);
/// </code>
/// </example>
/// <returns>A collection of DataType objects.</returns>
public ORMBiz.DataTypeCollection GetDataTypeCollectionFromDataSet()
{
DataRow[] DataTypeList = GetRows(DataSet, "DataType");
ORMBiz.DataTypeCollection a = new ORMBiz.DataTypeCollection();
foreach(DataRow dr in DataTypeList )
a.Add( new ORMBiz.DataType(this, dr));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Creates a new Param.
/// </summary>
/// <remarks>
/// <see cref="OrmLib.DataManagerBase.CommitAll"/> to have this written to the database.
/// </remarks>
/// <returns>A new Param object</returns>
public ORMBiz.Param NewParam()
{
DataRow dr = DataSet.Tables["Param"].NewRow();
DataSet.Tables["Param"].Rows.Add( dr );
ORMBiz.Param _Param = new ORMBiz.Param(this, dr);
return _Param;
}
/// <summary>
/// Gets a ORMBiz.Param based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <param name="relations">Specify which related tables should be fetched during this query</param>
/// <returns>A Param, or null if not found</returns>
public ORMBiz.Param GetParam(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet( CreateSql("Param", relations), ds, false);
DataRow ParamRow = GetRow(ds, "Param");
if ( ParamRow == null ) return null;
return new ORMBiz.Param (this, ParamRow);
}
/// <summary>
/// Gets a ORMBiz.Param from the already loaded records in this DataManager, by primary key.
/// </summary>
/// <remarks>
/// This method is made available for when the dataset has been serialized
/// from session state or disk.
/// </remarks>
/// <example>
/// This example shows a reason to use this method.
/// <code>
/// /* first web page - save dataset and primary keys */
/// Session["DataSet"] = dm.DataSet;
/// Session["ParamID"] = _Param.ID;
///
/// /* second web page - need to get currend contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Param = dm.GetContactFromDataSet((System.Int32)Session["ParamID"]);
/// </code>
/// </example>
/// <param name="ID">Primary key of the data row to retrieve.</param>
/// <returns>A Param, or null if not found</returns>
public ORMBiz.Param GetParamFromDataSet(System.Int32 ID)
{
DataRow ParamRow = null;
foreach(DataRow dr in DataSet.Tables["Param"].Rows)
{
if ( ((System.Int32)dr["ID"]).ToString() == ID.ToString() )
{
ParamRow = dr;
break;
}
}
if ( ParamRow == null) return null;
return new ORMBiz.Param (this, ParamRow);
}
/// <summary>
/// Gets multiple Params based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <returns>A collection of Param objects</returns>
public ORMBiz.ParamCollection GetParamCollection()
{
return GetParamCollection(FetchPath.Param);
}
/// <summary>
/// Gets multiple Params based on the criteria specified by AddCriteria(..).
/// </summary>
/// <param name="relations">Specify which related tables should be fetched during this query</param>
/// <returns>A collection of Param objects</returns>
public ORMBiz.ParamCollection GetParamCollection(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet(CreateSql("Param", relations), ds, false);
DataRow[] ParamList = GetRows(ds,"Param");
if ( ParamList == null ) return null;
ORMBiz.ParamCollection a = new ORMBiz.ParamCollection();
foreach ( DataRow dr in ParamList )
a.Add(new ORMBiz.Param( this, dr ));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Gets a collection of Param from the already loaded records in this DataManager instance.
/// </summary>
/// <remarks>
/// This method is made available for when the dataset has been serialized
/// from session state or disk. This method will return all Param loaded.
/// </remarks>
/// <example>
/// This example shows a reason to use this method.
/// <code>
/// /* first web page - save dataset and primary keys */
/// Session["DataSet"] = dm.DataSet;
/// Session["ParamID"] = _Param.ID;
///
/// /* second web page - need to get current contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Param = dm.GetContactFromDataSet((int)Session["ParamID"]);
/// </code>
/// </example>
/// <returns>A collection of Param objects.</returns>
public ORMBiz.ParamCollection GetParamCollectionFromDataSet()
{
DataRow[] ParamList = GetRows(DataSet, "Param");
ORMBiz.ParamCollection a = new ORMBiz.ParamCollection();
foreach(DataRow dr in ParamList )
a.Add( new ORMBiz.Param(this, dr));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Creates a new Procedure.
/// </summary>
/// <remarks>
/// <see cref="OrmLib.DataManagerBase.CommitAll"/> to have this written to the database.
/// </remarks>
/// <returns>A new Procedure object</returns>
public ORMBiz.Procedure NewProcedure()
{
DataRow dr = DataSet.Tables["Procedure"].NewRow();
DataSet.Tables["Procedure"].Rows.Add( dr );
ORMBiz.Procedure _Procedure = new ORMBiz.Procedure(this, dr);
return _Procedure;
}
/// <summary>
/// Gets a ORMBiz.Procedure based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <param name="relations">Specify which related tables should be fetched during this query</param>
/// <returns>A Procedure, or null if not found</returns>
public ORMBiz.Procedure GetProcedure(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet( CreateSql("Procedure", relations), ds, false);
DataRow ProcedureRow = GetRow(ds, "Procedure");
if ( ProcedureRow == null ) return null;
return new ORMBiz.Procedure (this, ProcedureRow);
}
/// <summary>
/// Gets a ORMBiz.Procedure from the already loaded records in this DataManager, by primary key.
/// </summary>
/// <remarks>
/// This method is made available for when the dataset has been serialized
/// from session state or disk.
/// </remarks>
/// <example>
/// This example shows a reason to use this method.
/// <code>
/// /* first web page - save dataset and primary keys */
/// Session["DataSet"] = dm.DataSet;
/// Session["ProcedureID"] = _Procedure.ID;
///
/// /* second web page - need to get currend contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Procedure = dm.GetContactFromDataSet((System.Int32)Session["ProcedureID"]);
/// </code>
/// </example>
/// <param name="ID">Primary key of the data row to retrieve.</param>
/// <returns>A Procedure, or null if not found</returns>
public ORMBiz.Procedure GetProcedureFromDataSet(System.Int32 ID)
{
DataRow ProcedureRow = null;
foreach(DataRow dr in DataSet.Tables["Procedure"].Rows)
{
if ( ((System.Int32)dr["ID"]).ToString() == ID.ToString() )
{
ProcedureRow = dr;
break;
}
}
if ( ProcedureRow == null) return null;
return new ORMBiz.Procedure (this, ProcedureRow);
}
/// <summary>
/// Gets multiple Procedures based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <returns>A collection of Procedure objects</returns>
public ORMBiz.ProcedureCollection GetProcedureCollection()
{
return GetProcedureCollection(FetchPath.Procedure);
}
/// <summary>
/// Gets multiple Procedures based on the criteria specified by AddCriteria(..).
/// </summary>
/// <param name="relations">Specify which related tables should be fetched during this query</param>
/// <returns>A collection of Procedure objects</returns>
public ORMBiz.ProcedureCollection GetProcedureCollection(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet(CreateSql("Procedure", relations), ds, false);
DataRow[] ProcedureList = GetRows(ds,"Procedure");
if ( ProcedureList == null ) return null;
ORMBiz.ProcedureCollection a = new ORMBiz.ProcedureCollection();
foreach ( DataRow dr in ProcedureList )
a.Add(new ORMBiz.Procedure( this, dr ));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Gets a collection of Procedure from the already loaded records in this DataManager instance.
/// </summary>
/// <remarks>
/// This method is made available for when the dataset has been serialized
/// from session state or disk. This method will return all Procedure loaded.
/// </remarks>
/// <example>
/// This example shows a reason to use this method.
/// <code>
/// /* first web page - save dataset and primary keys */
/// Session["DataSet"] = dm.DataSet;
/// Session["ProcedureID"] = _Procedure.ID;
///
/// /* second web page - need to get current contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Procedure = dm.GetContactFromDataSet((int)Session["ProcedureID"]);
/// </code>
/// </example>
/// <returns>A collection of Procedure objects.</returns>
public ORMBiz.ProcedureCollection GetProcedureCollectionFromDataSet()
{
DataRow[] ProcedureList = GetRows(DataSet, "Procedure");
ORMBiz.ProcedureCollection a = new ORMBiz.ProcedureCollection();
foreach(DataRow dr in ProcedureList )
a.Add( new ORMBiz.Procedure(this, dr));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Creates a new Relation.
/// </summary>
/// <remarks>
/// <see cref="OrmLib.DataManagerBase.CommitAll"/> to have this written to the database.
/// </remarks>
/// <returns>A new Relation object</returns>
public ORMBiz.Relation NewRelation()
{
DataRow dr = DataSet.Tables["Relation"].NewRow();
DataSet.Tables["Relation"].Rows.Add( dr );
ORMBiz.Relation _Relation = new ORMBiz.Relation(this, dr);
return _Relation;
}
/// <summary>
/// Gets a ORMBiz.Relation based on the criteria specified by QueryCriteria.And(..).
/// </summary>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -