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
source share
1 answer

It does not look like it was implemented. See the code here . I would suggest that this is for performance reasons.

0
source

Source: https://habr.com/ru/post/1547080/


All Articles