📄 datamanager.cs
字号:
/// <param name="relations">Specify which related tables should be fetched during this query</param>
/// <returns>A Relation, or null if not found</returns>
public ORMBiz.Relation GetRelation(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet( CreateSql("Relation", relations), ds, false);
DataRow RelationRow = GetRow(ds, "Relation");
if ( RelationRow == null ) return null;
return new ORMBiz.Relation (this, RelationRow);
}
/// <summary>
/// Gets a ORMBiz.Relation 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["RelationID"] = _Relation.ID;
///
/// /* second web page - need to get currend contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Relation = dm.GetContactFromDataSet((System.Int32)Session["RelationID"]);
/// </code>
/// </example>
/// <param name="ID">Primary key of the data row to retrieve.</param>
/// <returns>A Relation, or null if not found</returns>
public ORMBiz.Relation GetRelationFromDataSet(System.Int32 ID)
{
DataRow RelationRow = null;
foreach(DataRow dr in DataSet.Tables["Relation"].Rows)
{
if ( ((System.Int32)dr["ID"]).ToString() == ID.ToString() )
{
RelationRow = dr;
break;
}
}
if ( RelationRow == null) return null;
return new ORMBiz.Relation (this, RelationRow);
}
/// <summary>
/// Gets multiple Relations based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <returns>A collection of Relation objects</returns>
public ORMBiz.RelationCollection GetRelationCollection()
{
return GetRelationCollection(FetchPath.Relation);
}
/// <summary>
/// Gets multiple Relations 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 Relation objects</returns>
public ORMBiz.RelationCollection GetRelationCollection(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet(CreateSql("Relation", relations), ds, false);
DataRow[] RelationList = GetRows(ds,"Relation");
if ( RelationList == null ) return null;
ORMBiz.RelationCollection a = new ORMBiz.RelationCollection();
foreach ( DataRow dr in RelationList )
a.Add(new ORMBiz.Relation( this, dr ));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Gets a collection of Relation 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 Relation 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["RelationID"] = _Relation.ID;
///
/// /* second web page - need to get current contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Relation = dm.GetContactFromDataSet((int)Session["RelationID"]);
/// </code>
/// </example>
/// <returns>A collection of Relation objects.</returns>
public ORMBiz.RelationCollection GetRelationCollectionFromDataSet()
{
DataRow[] RelationList = GetRows(DataSet, "Relation");
ORMBiz.RelationCollection a = new ORMBiz.RelationCollection();
foreach(DataRow dr in RelationList )
a.Add( new ORMBiz.Relation(this, dr));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Creates a new RelationColumn.
/// </summary>
/// <remarks>
/// <see cref="OrmLib.DataManagerBase.CommitAll"/> to have this written to the database.
/// </remarks>
/// <returns>A new RelationColumn object</returns>
public ORMBiz.RelationColumn NewRelationColumn()
{
DataRow dr = DataSet.Tables["RelationColumn"].NewRow();
DataSet.Tables["RelationColumn"].Rows.Add( dr );
ORMBiz.RelationColumn _RelationColumn = new ORMBiz.RelationColumn(this, dr);
return _RelationColumn;
}
/// <summary>
/// Gets a ORMBiz.RelationColumn 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 RelationColumn, or null if not found</returns>
public ORMBiz.RelationColumn GetRelationColumn(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet( CreateSql("RelationColumn", relations), ds, false);
DataRow RelationColumnRow = GetRow(ds, "RelationColumn");
if ( RelationColumnRow == null ) return null;
return new ORMBiz.RelationColumn (this, RelationColumnRow);
}
/// <summary>
/// Gets a ORMBiz.RelationColumn 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["RelationColumnID"] = _RelationColumn.ID;
///
/// /* second web page - need to get currend contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _RelationColumn = dm.GetContactFromDataSet((System.Int32)Session["RelationColumnID"]);
/// </code>
/// </example>
/// <param name="ID">Primary key of the data row to retrieve.</param>
/// <returns>A RelationColumn, or null if not found</returns>
public ORMBiz.RelationColumn GetRelationColumnFromDataSet(System.Int32 ID)
{
DataRow RelationColumnRow = null;
foreach(DataRow dr in DataSet.Tables["RelationColumn"].Rows)
{
if ( ((System.Int32)dr["ID"]).ToString() == ID.ToString() )
{
RelationColumnRow = dr;
break;
}
}
if ( RelationColumnRow == null) return null;
return new ORMBiz.RelationColumn (this, RelationColumnRow);
}
/// <summary>
/// Gets multiple RelationColumns based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <returns>A collection of RelationColumn objects</returns>
public ORMBiz.RelationColumnCollection GetRelationColumnCollection()
{
return GetRelationColumnCollection(FetchPath.RelationColumn);
}
/// <summary>
/// Gets multiple RelationColumns 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 RelationColumn objects</returns>
public ORMBiz.RelationColumnCollection GetRelationColumnCollection(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet(CreateSql("RelationColumn", relations), ds, false);
DataRow[] RelationColumnList = GetRows(ds,"RelationColumn");
if ( RelationColumnList == null ) return null;
ORMBiz.RelationColumnCollection a = new ORMBiz.RelationColumnCollection();
foreach ( DataRow dr in RelationColumnList )
a.Add(new ORMBiz.RelationColumn( this, dr ));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Gets a collection of RelationColumn 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 RelationColumn 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["RelationColumnID"] = _RelationColumn.ID;
///
/// /* second web page - need to get current contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _RelationColumn = dm.GetContactFromDataSet((int)Session["RelationColumnID"]);
/// </code>
/// </example>
/// <returns>A collection of RelationColumn objects.</returns>
public ORMBiz.RelationColumnCollection GetRelationColumnCollectionFromDataSet()
{
DataRow[] RelationColumnList = GetRows(DataSet, "RelationColumn");
ORMBiz.RelationColumnCollection a = new ORMBiz.RelationColumnCollection();
foreach(DataRow dr in RelationColumnList )
a.Add( new ORMBiz.RelationColumn(this, dr));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Creates a new Table.
/// </summary>
/// <remarks>
/// <see cref="OrmLib.DataManagerBase.CommitAll"/> to have this written to the database.
/// </remarks>
/// <returns>A new Table object</returns>
public ORMBiz.Table NewTable(System.String IsLookupTable)
{
DataRow dr = DataSet.Tables["Table"].NewRow();
DataSet.Tables["Table"].Rows.Add( dr );
ORMBiz.Table _Table = new ORMBiz.Table(this, dr);
_Table.IsLookupTable = IsLookupTable;
return _Table;
}
/// <summary>
/// Gets a ORMBiz.Table 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 Table, or null if not found</returns>
public ORMBiz.Table GetTable(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet( CreateSql("Table", relations), ds, false);
DataRow TableRow = GetRow(ds, "Table");
if ( TableRow == null ) return null;
return new ORMBiz.Table (this, TableRow);
}
/// <summary>
/// Gets a ORMBiz.Table 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["TableID"] = _Table.ID;
///
/// /* second web page - need to get currend contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Table = dm.GetContactFromDataSet((System.Int32)Session["TableID"]);
/// </code>
/// </example>
/// <param name="ID">Primary key of the data row to retrieve.</param>
/// <returns>A Table, or null if not found</returns>
public ORMBiz.Table GetTableFromDataSet(System.Int32 ID)
{
DataRow TableRow = null;
foreach(DataRow dr in DataSet.Tables["Table"].Rows)
{
if ( ((System.Int32)dr["ID"]).ToString() == ID.ToString() )
{
TableRow = dr;
break;
}
}
if ( TableRow == null) return null;
return new ORMBiz.Table (this, TableRow);
}
/// <summary>
/// Gets multiple Tables based on the criteria specified by QueryCriteria.And(..).
/// </summary>
/// <returns>A collection of Table objects</returns>
public ORMBiz.TableCollection GetTableCollection()
{
return GetTableCollection(FetchPath.Table);
}
/// <summary>
/// Gets multiple Tables 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 Table objects</returns>
public ORMBiz.TableCollection GetTableCollection(params DataManagerBase.FetchPathRelation[] relations)
{
DataSet ds = new DataSet();
FillDataSet(CreateSql("Table", relations), ds, false);
DataRow[] TableList = GetRows(ds,"Table");
if ( TableList == null ) return null;
ORMBiz.TableCollection a = new ORMBiz.TableCollection();
foreach ( DataRow dr in TableList )
a.Add(new ORMBiz.Table( this, dr ));
// must be added afterwards
a.DataManager = this;
return a;
}
/// <summary>
/// Gets a collection of Table 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 Table 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["TableID"] = _Table.ID;
///
/// /* second web page - need to get current contact */
/// DataManager dm = new DataManager(Config.Dsn);
/// dm.DataSet = (DataSet)Session["DataSet"];
/// _Table = dm.GetContactFromDataSet((int)Session["TableID"]);
/// </code>
/// </example>
/// <returns>A collection of Table objects.</returns>
public ORMBiz.TableCollection GetTableCollectionFromDataSet()
{
DataRow[] TableList = GetRows(DataSet, "Table");
ORMBiz.TableCollection a = new ORMBiz.TableCollection();
foreach(DataRow dr in TableList )
a.Add( new ORMBiz.Table(this, dr));
// must be added afterwards
a.DataManager = this;
return a;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -