示例#1
0
        public async Task Should_insert_int_with_streaming_disabled()
        {
            ConfigureModel = builder => builder.ConfigureTempTable <int>();

            var options = new SqlTempTableBulkInsertOptions {
                BulkInsertOptions = { EnableStreaming = false }
            };
            var values = new List <int> {
                1, 2
            };
            var query = await ActDbContext.BulkInsertValuesIntoTempTableAsync(values, options).ConfigureAwait(false);

            var tempTable = await query.ToListAsync().ConfigureAwait(false);

            tempTable.Should()
            .HaveCount(2).And
            .BeEquivalentTo(new TempTable <int>(1), new TempTable <int>(2));
        }
示例#2
0
        public static Task <IQueryable <TempTable <TColumn1> > > BulkInsertValuesIntoTempTableAsync <TColumn1>([NotNull] this DbContext ctx,
                                                                                                               [NotNull] IEnumerable <TColumn1> values,
                                                                                                               [CanBeNull] SqlTempTableBulkInsertOptions options = null,
                                                                                                               CancellationToken cancellationToken = default)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            var entities = values.Select(v => new TempTable <TColumn1>(v));

            return(ctx.BulkInsertIntoTempTableAsync(entities, options, cancellationToken));
        }