Table "Groups" is a custom table(no model to match) and has an Id set to be auto increment in SQL Server. This is the code to insert a new record using PetaPoco ORM:
Database.Insert("Groups", new { GroupName = "testGroup", CreatedOn = DateTime.Now });
What I need to do is to take this auto generated id back after insert. Is there any work around for this?
Any help is welcome!
PetaPoco tries to figure out if there is an auto increment on PK column, and returns it if there is. Does it return anything in your case?
Besides, you can also use another Insert overload and explicitly mention the PK column and the fact that there is an auto incremented id you want back:
object id = Database.Insert("Groups", "GroupID", true,
new { GroupName = "testGroup", CreatedOn = DateTime.Now });