PrimaryKeys Property
Gets the names of the columns that form the primary key. This list is derived from IColumnMetadata.IsPrimaryKey flags.
Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll
/// <summary>
/// Gets the names of the columns that form the primary key.
/// This list is derived from IColumnMetadata.IsPrimaryKey flags.
/// </summary>
public IReadOnlyList<string> PrimaryKeys
{
get;
}
// 1) Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();
// 2) Add Department data table to data set
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);
departmentDataTable.AddColumn("DepartmentId", DataTypeNames.INT32);
// 3) Get the list of primary key column names
// Observe that the list contains one only "Id" column as it is the only column with IsPrimaryKey flag set to true
// The "Id" column is considered as the primary key column because it is generally accepted that "Id" means the name of the primary key column.
IReadOnlyList<string> primaryKeyColumnNames = departmentDataTable.PrimaryKeys;
Table of Content POCO DataSet API References POCO DataSet Types DataTable 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.