public PocoMapper(DbDataReader reader) { _reader = reader; _pocoTable = new PocoTable <T>(); //_fieldMappings = new List<PocoTableMapping>(); ////Create a list of properties in the type T, and match them to ordinals in the inputReader. //var properties = typeof(T).GetProperties(); //foreach (var propertyInfo in properties) //{ // // if the property has a field attribute, use this as the reference in the reader // var field = propertyInfo.GetCustomAttribute<PocoColumnAttribute>(false); // if (field != null && !field.Skip) // { // var name = string.IsNullOrEmpty(field?.Name) ? propertyInfo.Name : field.Name; // var isKey = field != null && field.IsKey; // var ordinal = reader.GetOrdinal(name); // if (ordinal >= 0) // { // _fieldMappings.Add(new PocoTableMapping(propertyInfo, ordinal, isKey)); // } // } //} }
/// <summary> /// Inserts the items into the connection. /// </summary> /// <returns>The insert.</returns> /// <param name="connection">Connection.</param> /// <param name="items">Item.</param> /// <param name="cancellationToken">Cancellation token.</param> public async Task ExecuteInsertBulk(Connection connection, IEnumerable <T> items, CancellationToken cancellationToken) { var pocoTable = new PocoTable <T>(Table.Copy()); var pocoReader = new PocoReader <T>(pocoTable, items); await connection.ExecuteInsertBulk(Table, pocoReader, cancellationToken); }
public PocoMapper(DbDataReader reader, PocoTable <T> pocoTable) { _reader = reader; _pocoTable = pocoTable; }