Using Dapper extensions, you can get identifiers when inserting IEnumerable <T>
If an object is inserted one at a time, then Id can be extracted from the object:
foreach (var object in objectList)
{
conn.Insert(object);
int id = object.Id; // Returns Id as expected
}
However, if IEnumerable objects are inserted, identifiers cannot be correctly selected:
conn.Insert(objectList);
foreach (var object in objectList)
{
int id = object.Id; // Returning 0
}
Is there a way to insert a list of objects and still return identifiers without inserting 1 at a time?
+4