R – Getting Record ID after saving with SubSonic 2.2

primary-keysubsonic

How do I get the Record ID (Primary Key) immediately after saving a record? I have the ID column as auto generated. I need to pass the ID to another object as a "Foreign Key" before saving that object.

Currently I do

Product.Save()

Can't I do

int id = Product.Save()

Best Answer

You can simply do

Product.Save();
int id = Product.ID; //or whatever your ID column is