TypedList primary key

Posts   
 
    
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 05-Oct-2010 15:03:42   

There is a property named "PrimaryKey". I have this property always null. How can be this property set ?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 05-Oct-2010 19:42:57   

It can't - Typed Lists are read only. Is this property coming from an existing table - ie, do you have a column actually called "PrimaryKey" ? And is it a primary key on the table ?

Matt

methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 05-Oct-2010 23:12:03   

No this property is part of the base class DataTable. So this property cannot be set ? Its just a needless property from DataTable ?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 06-Oct-2010 00:15:35   

Sorry. my misunderstanding. Yes, it's a hangover from the fact that TypedLists inherit from DataTables. Because DataTables can also be used to represent single tables, they need a property to set and read the PrimaryKey columns. It can be safely ignored for your purposes.

http://msdn.microsoft.com/en-us/library/system.data.datatable.primarykey.aspx

Matt