Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Find Primary Key Column View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/30/2012 6:21:11 PM
   
Find Primary Key Column
How can I find the primary key column/property of a DataClassInfo object? I can easily get a list of properties for a class name like so:

DataClassInfo dci = DataClassInfoProvider.GetDataClass(CustomTableName);
List<string> columns = dci.Properties;

But unsure how to find out which one of those columns is a primary key or get any attributes from any of those properties like datatype or allow nulls or default value.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/30/2012 11:10:02 PM
   
RE:Find Primary Key Column
Found my answer, need to use this:

IDataClass dc = DataClassFactory.NewDataClass(className);
string idColumn = dc.IDColumn;

Had some assistance from this post.