Table of Contents

Class DbObject

Namespace
Dynamicweb.Data
Assembly
Dynamicweb.Data.dll
Class contains function for data base objects handling.
[Serializable]
public abstract class DbObject
Inheritance
DbObject
Inherited Members

Constructors

DbObject(string, string)

Initializes a new instance of the DbObject class.
protected DbObject(string tableName, string keyField)

Parameters

tableName string
Name of the table.
keyField string
The key field.

Fields

_id

The ID (primary key) of the instance of the DBobject
protected int _id

Field Value

int

_keyField

Name of the primary key field of the table
protected string _keyField

Field Value

string

_tableName

Name of table in the database where data for this record are kept.
protected string _tableName

Field Value

string

Properties

Connection

Connection to the database that can be overriden if operation on a series of objects needs to be done in the context of a transaction
[Obsolete("Do not use")]
public IDbConnection Connection { get; set; }

Property Value

IDbConnection

ID

Store and retrieves the current object ID - usually the primary key of the table storing the data.
public int ID { get; set; }

Property Value

int
Object ID.

IsNew

Indicates whether the current object is new.
public bool IsNew { get; }

Property Value

bool
Boolean statement.

Transaction

Transaction if operation on a series of objects needs to be done in the context of a transaction
[Obsolete("Do not use")]
public IDbTransaction Transaction { get; set; }

Property Value

IDbTransaction

Methods

Delete()

Deletes the current instance of this object based on its ID.
public void Delete()

Delete(int)

Deletes the object with specified ID.
public virtual void Delete(int id)

Parameters

id int
Specified ID.

ExecuteDbObject<T>(CommandBuilder)

Executes the query and returns DbObject from the the first row in the result set returned by the query. All other rows are ignored.
[Obsolete("Do not use")]
public static T ExecuteDbObject<T>(CommandBuilder commandBuilder) where T : DbObject, new()

Parameters

commandBuilder CommandBuilder
The CommandBuilder.

Returns

T
If query returns a result an instance of a DbObject derived type; otherwise null (Nothing in Visual Basic).

Type Parameters

T
DbObject derived type containing a parameterless constructor.

ExecuteList<T>(CommandBuilder)

Executes the query and returns list of DBObject objects in the result set returned by the query.
[Obsolete("Do not use")]
public static List<T> ExecuteList<T>(CommandBuilder commandBuilder) where T : DbObject, new()

Parameters

commandBuilder CommandBuilder
The CommandBuilder containing the query.

Returns

List<T>
If query returns a result a List<T> containing instances of the DbObject derived type; otherwise an empty List<T>.

Type Parameters

T
DbObject derived type containing a parameterless constructor.

ExecuteList<T>(string)

Executes the query and returns list of DBObject objects in the result set returned by the query.
[Obsolete("Do not use")]
public static List<T> ExecuteList<T>(string sql) where T : DbObject, new()

Parameters

sql string
The query.

Returns

List<T>
If query returns a result a List<T> containing instances of the DbObject derived type; otherwise an empty List<T>.

Type Parameters

T
DbObject derived type containing a parameterless constructor.

ExecuteList<TCollection, T>(CommandBuilder)

Executes the query and returns a collection of DBObject objects in the result set returned by the query.
[Obsolete("Do not use")]
public static TCollection ExecuteList<TCollection, T>(CommandBuilder commandBuilder) where TCollection : List<T>, new() where T : DbObject, new()

Parameters

commandBuilder CommandBuilder
The CommandBuilder containing the query.

Returns

TCollection
If query returns a result a List<T> containing instances of the DbObject derived type; otherwise an empty List<T>.

Type Parameters

TCollection
List<T> derived type containing a parameterless constructor.
T
DbObject derived type containing a parameterless constructor.

ExecuteList<TCollection, T>(string)

Executes the query and returns a collection of DBObject objects in the result set returned by the query.
[Obsolete("Do not use")]
public static TCollection ExecuteList<TCollection, T>(string sql) where TCollection : List<T>, new() where T : DbObject, new()

Parameters

sql string
The query.

Returns

TCollection
If query returns a result a List<T> containing instances of the DbObject derived type; otherwise an empty List<T>.

Type Parameters

TCollection
List<T> derived type containing a parameterless constructor.
T
DbObject derived type containing a parameterless constructor.

Fill(IDataReader)

Override the fill method to map all the properties values to their respective field on the provided data reader. Used when an instance of the object type is loaded from the database.
public abstract void Fill(IDataReader reader)

Parameters

reader IDataReader
The datareader instance with the data.

FillRow(DataRow)

Override the FillRow method to map all the properties values to their respective field on the datarow. Used when the object is being saved.
protected abstract void FillRow(DataRow row)

Parameters

row DataRow
The datarow to fill with data.

Load(int)

Loads data from the current ID row.
public virtual void Load(int id)

Parameters

id int
ID of the current row.

Save()

Saves current data to the data base.
public virtual void Save()
To top