AddNewTableFromPocoInterface Method

Overview

The AddNewTableFromPocoInterface method adds a new IObservableDataTable to an IObservableDataSet and builds the table schema by reflecting over a POCO interface type. It creates the table, assigns the table name, adds it to the data set, and then calls AddColumnsFromInterface(Type) to populate column metadata based on the interface properties.

Declaration

/// <summary>
/// Adds a new observable table to observable data set using POCO interface type (delegates to inner data set)
/// </summary>
/// <typeparam name="TInterface">Interface type</typeparam>
/// <param name="observableDataSet">Observable data set</param>
/// <param name="tableName">Table name</param>
/// <param name="interfaceType">Interface type</param>
/// <returns>New observable table</returns>
/// <exception cref="KeyDuplicationException">Exception is thrown if dataset contains a table with specified name already</exception>
public static IObservableDataTable AddNewTableFromPocoInterface(this IObservableDataSet? observableDataSet, string tableName, Type interfaceType)

Namespace and Assembly

Namespace: PocoDataSet.ObservableExtensions
Assembly: PocoDataSet.ObservableExtensions.dll

Usage Example

Assume there is an interface that describes the schema of an EmploymentType entity:

/// <summary>
/// Defines employment type functionality
/// </summary>
internal interface IEmploymentType
{
  string Code { get; set; }
  string? Description { get; set; }
  int Id { get; set; }
}

You can create a table with schema based on this interface in a single call:

// 1. Create an observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();

// 2. Create observable data table with schema loaded from POCO interface
IObservableDataTable employmentTypeObservableDataTable = observableDataSet.AddNewTableFromPocoInterface("EmploymentType", typeof(IEmploymentType));

 

Table of Content POCO DataSet Observable Data Set Members

 


Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness or suitability of the information and are not responsible for any damages resulting from its use.