5

If an object is inserted 1 at a time, then the Id can be fetched from the object:

foreach (var object in objectList)
{
    conn.Insert(object);
    int id = object.Id; // Returns Id as expected
}

However, if an IEnumerable of objects is inserted, the Ids cannot be fetched properly:

conn.Insert(objectList);
foreach (var object in objectList)
{
    int id = object.Id; // Returning 0
}

Is there a way to insert the list of objects and still get the Ids back without inserting 1 at a time?

Kevin Crowell
  • 10,082
  • 4
  • 35
  • 51

1 Answers1

0

Doesn't look like that has been implemented. See the code here. I would assume this is for performance reasons.

mxmissile
  • 11,464
  • 3
  • 53
  • 79