Class DataSourceBase
Base class for all datasources such as TableDataSource.
Inheritance
Inherited Members
Namespace: FastReport.Data
Assembly: FastReport.dll
Syntax
[TypeConverter(typeof(DataSourceConverter))]
public abstract class DataSourceBase : Column, IDisposable, IFRSerializable, IParent
Constructors
DataSourceBase()
Initializes a new instance of the DataSourceBase class with default settings.
Declaration
public DataSourceBase()
Fields
currentRow
Declaration
protected object currentRow
Field Value
| Type | Description |
|---|---|
| System.Object |
Properties
Alias
Gets or sets alias of this object.
Declaration
public string Alias { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
Alias is a human-friendly name of this object. It may contain any symbols (including spaces and national symbols).
BindableControl
This property is not relevant to this class.
Declaration
[Browsable(false)]
public ColumnBindableControl BindableControl { get; set; }
Property Value
| Type | Description |
|---|---|
| ColumnBindableControl |
Calculated
This property is not relevant to this class.
Declaration
[Browsable(false)]
public bool Calculated { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
CurrentRow
Gets the current data row.
Declaration
[Browsable(false)]
public object CurrentRow { get; }
Property Value
| Type | Description |
|---|---|
| System.Object |
Remarks
This property is updated when you call the Next() method.
CurrentRowNo
Gets an index of current data row.
Declaration
[Browsable(false)]
public int CurrentRowNo { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
You should initialize the datasource by the Init method before using this property.
This property is updated when you call the Next() method.
CustomBindableControl
This property is not relevant to this class.
Declaration
[Browsable(false)]
public string CustomBindableControl { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataType
This property is not relevant to this class.
Declaration
[Browsable(false)]
public Type DataType { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Type |
Expression
This property is not relevant to this class.
Declaration
[Browsable(false)]
public string Expression { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ForceLoadData
Forces loading of data for this datasource.
Declaration
public bool ForceLoadData { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
This property is false by default. Set it to true if you need to reload data each time when the datasource initialized. Note that this may slow down the performance.
Format
This property is not relevant to this class.
Declaration
[Browsable(false)]
public ColumnFormat Format { get; set; }
Property Value
| Type | Description |
|---|---|
| ColumnFormat |
HasMoreRows
Gets a value indicating that datasource has more rows, that is the CurrentRowNo is less than the RowCount.
Declaration
[Browsable(false)]
public bool HasMoreRows { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
You should initialize the datasource by the Init method before using this property.
Usually this property is used with the following code block:
dataSource.Init();
while (dataSource.HasMoreRows)
{
// do something...
dataSource.Next();
}
Item[Column]
Gets data stored in a specified column.
Declaration
[Browsable(false)]
public object this[Column column] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| Column | column | The column. |
Property Value
| Type | Description |
|---|---|
| System.Object | The column's value. |
Remarks
You should initialize the datasource by the Init method before using this property.
Item[String]
Gets data stored in a specified column.
Declaration
[Browsable(false)]
public object this[string columnAlias] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | columnAlias | Alias of a column. |
Property Value
| Type | Description |
|---|---|
| System.Object | The column's value. |
Remarks
You should initialize the datasource by the Init method before using this property.
RowCount
Gets a number of data rows in this datasource.
Declaration
[Browsable(false)]
public int RowCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
You should initialize the datasource by the Init method before using this property.
Methods
Deserialize(FRReader)
Deserializes the object.
Declaration
public override void Deserialize(FRReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| FRReader | reader | Reader object. |
Overrides
Remarks
Do not call this method directly. You should override it if you are developing a new component for FastReport.
This method is called when the object needs to restore the state. It may happen when:
- loading the report from a file or stream;
- loading the report from the designer's undo buffer;
- assigning another object to this object using the Assign(Base) or AssignAll methods;
- loading the object from the designer's clipboard;
- loading the object from the preview pages.
EnsureInit()
Initializes the data source if it is not initialized yet.
Declaration
public void EnsureInit()
EnsureInitAsync(CancellationToken)
Initializes the data source if it is not initialized yet.
Declaration
public async Task EnsureInitAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
First()
Navigates to the first row.
Declaration
public void First()
Remarks
You should initialize the datasource by the Init method before using this method.
GetValue(Column)
Gets data stored in a specified column.
Declaration
protected abstract object GetValue(Column column)
Parameters
| Type | Name | Description |
|---|---|---|
| Column | column | The column. |
Returns
| Type | Description |
|---|---|
| System.Object | An object that contains the data. |
GetValue(String)
Gets data stored in a specified column.
Declaration
protected virtual object GetValue(string alias)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | alias | The column alias. |
Returns
| Type | Description |
|---|---|
| System.Object | An object that contains the data. |
Init()
Initializes this datasource.
Declaration
public void Init()
Remarks
This method fills the table with data. You should always call it before using most of datasource properties.
Init(DataSourceBase)
Initializes this datasource and filters data rows according to the master-detail relation between this datasource and parentData.
Declaration
public void Init(DataSourceBase parentData)
Parameters
| Type | Name | Description |
|---|---|---|
| DataSourceBase | parentData | Parent datasource. |
Remarks
To use master-detail relation, you must define the Relation object that describes the relation, and add it to the Report.Dictionary.Relations collection.
Init(DataSourceBase, String, SortCollection)
Initializes this datasource and filters data rows according to the master-detail relation between this datasource and parentData. Also applies the specified filter and sorts the rows.
Declaration
public void Init(DataSourceBase parentData, string filter, SortCollection sort)
Parameters
| Type | Name | Description |
|---|---|---|
| DataSourceBase | parentData | Parent datasource. |
| System.String | filter | The filter expression. |
| SortCollection | sort | The collection of sort descriptors. |
Remarks
To use master-detail relation, you must define the Relation object that describes the relation, and add it to the Report.Dictionary.Relations collection.
Init(Relation, String, SortCollection)
Initializes this datasource and filters data rows according to the master-detail relation. Also applies the specified filter and sorts the rows.
Declaration
public void Init(Relation relation, string filter, SortCollection sort)
Parameters
| Type | Name | Description |
|---|---|---|
| Relation | relation | The master-detail relation. |
| System.String | filter | The filter expression. |
| SortCollection | sort | The collection of sort descriptors. |
Remarks
To use master-detail relation, you must define the Relation object that describes the relation, and add it to the Report.Dictionary.Relations collection.
Init(String)
Initializes this datasource and applies the specified filter.
Declaration
public void Init(string filter)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filter | The filter expression. |
Init(String, SortCollection)
Initializes this datasource, applies the specified filter and sorts the rows.
Declaration
public void Init(string filter, SortCollection sort)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filter | The filter expression. |
| SortCollection | sort | The collection of sort descriptors. |
InitAsync(DataSourceBase, String, SortCollection, CancellationToken)
Initializes this datasource and filters data rows according to the master-detail relation between this datasource and parentData. Also applies the specified filter and sorts the rows.
Declaration
public Task InitAsync(DataSourceBase parentData, string filter, SortCollection sort, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| DataSourceBase | parentData | Parent datasource. |
| System.String | filter | The filter expression. |
| SortCollection | sort | The collection of sort descriptors. |
| System.Threading.CancellationToken | cancellationToken | Cancellation Token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Remarks
To use master-detail relation, you must define the Relation object that describes the relation, and add it to the Report.Dictionary.Relations collection.
InitAsync(DataSourceBase, CancellationToken)
Initializes this datasource and filters data rows according to the master-detail relation between this datasource and parentData.
Declaration
public Task InitAsync(DataSourceBase parentData, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| DataSourceBase | parentData | Parent datasource. |
| System.Threading.CancellationToken | cancellationToken | Cancellation Token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Remarks
To use master-detail relation, you must define the Relation object that describes the relation, and add it to the Report.Dictionary.Relations collection.
InitAsync(Relation, String, SortCollection, CancellationToken)
Initializes this datasource and filters data rows according to the master-detail relation. Also applies the specified filter and sorts the rows.
Declaration
public Task InitAsync(Relation relation, string filter, SortCollection sort, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Relation | relation | The master-detail relation. |
| System.String | filter | The filter expression. |
| SortCollection | sort | The collection of sort descriptors. |
| System.Threading.CancellationToken | cancellationToken | Cancellation Token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Remarks
To use master-detail relation, you must define the Relation object that describes the relation, and add it to the Report.Dictionary.Relations collection.
InitAsync(String, SortCollection, CancellationToken)
Initializes this datasource, applies the specified filter and sorts the rows.
Declaration
public Task InitAsync(string filter, SortCollection sort, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filter | The filter expression. |
| SortCollection | sort | The collection of sort descriptors. |
| System.Threading.CancellationToken | cancellationToken | Cancellation Token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
InitAsync(String, CancellationToken)
Initializes this datasource and applies the specified filter.
Declaration
public Task InitAsync(string filter, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filter | The filter expression. |
| System.Threading.CancellationToken | cancellationToken | Cancellation Token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
InitAsync(CancellationToken)
Initializes this datasource.
Declaration
public Task InitAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Remarks
This method fills the table with data. You should always call it before using most of datasource properties.
InitializeComponent()
Initializes the object before running a report.
Declaration
public override void InitializeComponent()
Overrides
Remarks
This method is used by the report engine, do not call it directly.
InitSchema()
Initializes the datasource schema.
Declaration
public abstract void InitSchema()
Remarks
This method is used to support the FastReport.Net infrastructure. Do not call it directly.
InitSchemaAsync(CancellationToken)
Initializes the datasource schema.
Declaration
public abstract Task InitSchemaAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Remarks
This method is used to support the FastReport.Net infrastructure. Do not call it directly.
LoadData(ArrayList)
Loads the datasource with data.
Declaration
public abstract void LoadData(ArrayList rows)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.ArrayList | rows | Rows to fill with data. |
Remarks
This method is used to support the FastReport.Net infrastructure. Do not call it directly.
LoadDataAsync(ArrayList, CancellationToken)
Loads the datasource with data.
Declaration
public abstract Task LoadDataAsync(ArrayList rows, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.ArrayList | rows | Rows to fill with data. |
| System.Threading.CancellationToken | cancellationToken | Cancellation Token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Remarks
This method is used to support the FastReport.Net infrastructure. Do not call it directly.
Next()
Navigates to the next row.
Declaration
public void Next()
Remarks
You should initialize the datasource by the Init method before using this method.
Prior()
Navigates to the prior row.
Declaration
public void Prior()
Remarks
You should initialize the datasource by the Init method before using this method.
Serialize(FRWriter)
Serializes the object.
Declaration
public override void Serialize(FRWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| FRWriter | writer | Writer object. |
Overrides
Remarks
Do not call this method directly. You should override it if you are developing a new component for FastReport.
This method is called when the object needs to save the state. It may happen when:
- saving the report to the file or stream;
- saving the report to the designer's undo buffer;
- assigning the object to another object using the Assign(Base) or AssignAll methods;
- saving the object to the designer's clipboard;
- saving the object to the preview (when run a report).
Events
Load
Occurs when the FastReport engine loads data source with data.
Declaration
public event EventHandler Load
Event Type
| Type | Description |
|---|---|
| System.EventHandler |
Remarks
Use this event if you want to implement load-on-demand. Event handler must load the data into the data object which this datasource is bound to (for example, the TableDataSource uses data from the DataTable object bound to the Table property).