private static BulkRequest CreateIndexBulkRequest <T>(IEnumerable <T> objects, IndexName index) where T : class { @objects.ThrowIfEmpty(nameof(objects)); var bulkRequest = new BulkRequest(index); var indexOps = @objects .Select(o => new BulkIndexOperation <T>(o)) .Cast <IBulkOperation>() .ToList(); bulkRequest.Operations = new BulkOperationsCollection <IBulkOperation>(indexOps); return(bulkRequest); }
private static BulkRequest CreateDeleteBulkRequest <T>(IEnumerable <T> objects, IndexName index) where T : class { // ReSharper disable once PossibleMultipleEnumeration objects.ThrowIfEmpty(nameof(objects)); var bulkRequest = new BulkRequest(index); // ReSharper disable once PossibleMultipleEnumeration var deletes = objects .Select(o => new BulkDeleteOperation <T>(o)) .Cast <IBulkOperation>() .ToList(); bulkRequest.Operations = new BulkOperationsCollection <IBulkOperation>(deletes); return(bulkRequest); }