corelibraries-devexpress-dot-dataaccess-dot-sql-dot-dataapi-4ea01c46.md
A table from the IResultSet data set.
Namespace : DevExpress.DataAccess.Sql.DataApi
Assembly : DevExpress.DataAccess.v25.2.dll
NuGet Package : DevExpress.DataAccess
public interface ITable :
IEnumerable<IRow>,
IEnumerable
Public Interface ITable
Inherits IEnumerable(Of IRow),
IEnumerable
The following members return ITable objects:
Use the SqlDataSource.Result property to access the collection of data tables and their relations from the current IResultSet. You can access the required table (an object implementing ITable ) by its index or name. To obtain master-detail relations for the specified table, use the ITable.DetailRelations property.
For each table, you can access its columns using the ITable.Columns property. This property returns the object implementing the IColumn interface. To obtain the column name and type, use the IColumn.Name and IColumn.Type properties, respectively.
You can also access individual table rows (objects implementing IRow) using index notation.
The following example illustrates how to use the SqlDataSource.Result property to extract all data records from an SqlDataSource and pass them to a corresponding DataTable object.
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Sql.DataApi;
using System;
using System.Data;
using System.Linq;
using System.Windows.Forms;
// ...
private void button1_Click(object sender, EventArgs e) {
XtraReport1 report = new XtraReport1();
SqlDataSource ds = report.DataSource as SqlDataSource;
ds.Fill();
ITable src = ds.Result["Categories"];
DataTable dest = new DataTable("Categories");
foreach (IColumn column in src.Columns)
dest.Columns.Add(column.Name, column.Type);
foreach (IRow row in src)
dest.Rows.Add(row.ToArray());
}
Imports DevExpress.DataAccess.Sql
Imports DevExpress.DataAccess.Sql.DataApi
Imports System
Imports System.Data
Imports System.Linq
Imports System.Windows.Forms
' ...
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim report As New XtraReport1()
Dim ds As SqlDataSource = TryCast(report.DataSource, SqlDataSource)
ds.Fill()
Dim src As ITable = ds.Result("Categories")
Dim dest As New DataTable("Categories")
For Each column As IColumn In src.Columns
dest.Columns.Add(column.Name, column.Type)
Next column
For Each row As IRow In src
dest.Rows.Add(row.ToArray())
Next row
End Sub
See Also