CockroachDbBulkInsertMapItem
A mapping class used to define a column mapping, with an optional explicit CockroachDbType, for the CockroachDB bulk operations.
This class extends BulkInsertMapItem with an optional, explicit RepoDb.Connector.CockroachDb.CockroachDbType to bind with for the mapped column. When not provided, the type is inferred from the entity property’s [CockroachDbType] attribute (if present) or, failing that, from the .NET CLR value itself.
Used by the CockroachDB BulkInsert, BulkMerge and BulkUpdate operations. Mappings are also type-checked up front: if a mapping’s source and destination CLR types are incompatible (other than the allowed Guid↔string and integral-to-integral widenings), the write throws an InvalidTypeException before anything is sent to CockroachDB.
Create a new Instance
var mapItem = new CockroachDbBulkInsertMapItem("SourceId", "DestinationId");
Or with an explicit CockroachDbType:
var mapItem = new CockroachDbBulkInsertMapItem("SourceName", "DestinationName", CockroachDbType.Text);
Usage for BulkOperations
var mappings = new []
{
new CockroachDbBulkInsertMapItem("FirstName", "FName"),
new CockroachDbBulkInsertMapItem("LastName", "LName")
};
using (var connection = new CockroachDbConnection(connectionString))
{
var people = GetPeople(100000);
connection.BulkInsert(people, mappings: mappings);
}
The same approach applies to BulkMerge and BulkUpdate. The
mappingsargument is optional — omitting it causes the library to auto-map columns by name (case-insensitive).