Class DbObject
- Namespace
- Dynamicweb.Data
- Assembly
- Dynamicweb.Core.dll
Class contains function for data base objects handling.
[Serializable]
public abstract class DbObject
- Inheritance
-
DbObject
- Derived
- Inherited Members
Constructors
DbObject(string, string)
Initializes a new instance of the DbObject class.
protected DbObject(string tableName, string keyField)
Parameters
Fields
_id
The ID (primary key) of the instance of the DBobject
protected int _id
Field Value
_keyField
Name of the primary key field of the table
protected string _keyField
Field Value
_tableName
Name of table in the database where data for this record are kept.
protected string _tableName
Field Value
Properties
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.
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
intSpecified ID.
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
IDataReaderThe 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
DataRowThe datarow to fill with data.
Load(int)
Loads data from the current ID row.
public virtual void Load(int id)
Parameters
id
intID of the current row.
Save()
Saves current data to the data base.
public virtual void Save()