@@ -331,15 +331,19 @@ internal List<Document> GetNextSetHelper()
331
331
SourceTable . UpdateRequestUserAgentDetails ( scanReq , isAsync : false ) ;
332
332
333
333
var scanResult = internalClient . Scan ( scanReq ) ;
334
- foreach ( var item in scanResult . Items )
334
+ if ( scanResult . Items != null )
335
335
{
336
- Document doc = SourceTable . FromAttributeMap ( item ) ;
337
- ret . Add ( doc ) ;
338
- if ( CollectResults )
336
+ foreach ( var item in scanResult . Items )
339
337
{
340
- Matches . Add ( doc ) ;
338
+ Document doc = SourceTable . FromAttributeMap ( item ) ;
339
+ ret . Add ( doc ) ;
340
+ if ( CollectResults )
341
+ {
342
+ Matches . Add ( doc ) ;
343
+ }
341
344
}
342
345
}
346
+
343
347
NextKey = scanResult . LastEvaluatedKey ;
344
348
if ( NextKey == null || NextKey . Count == 0 )
345
349
{
@@ -381,15 +385,19 @@ internal List<Document> GetNextSetHelper()
381
385
SourceTable . UpdateRequestUserAgentDetails ( queryReq , isAsync : false ) ;
382
386
383
387
var queryResult = internalClient . Query ( queryReq ) ;
384
- foreach ( var item in queryResult . Items )
388
+ if ( queryResult . Items != null )
385
389
{
386
- Document doc = SourceTable . FromAttributeMap ( item ) ;
387
- ret . Add ( doc ) ;
388
- if ( CollectResults )
390
+ foreach ( var item in queryResult . Items )
389
391
{
390
- Matches . Add ( doc ) ;
392
+ Document doc = SourceTable . FromAttributeMap ( item ) ;
393
+ ret . Add ( doc ) ;
394
+ if ( CollectResults )
395
+ {
396
+ Matches . Add ( doc ) ;
397
+ }
391
398
}
392
399
}
400
+
393
401
NextKey = queryResult . LastEvaluatedKey ;
394
402
if ( NextKey == null || NextKey . Count == 0 )
395
403
{
@@ -445,15 +453,19 @@ internal async Task<List<Document>> GetNextSetHelperAsync(CancellationToken canc
445
453
SourceTable . UpdateRequestUserAgentDetails ( scanReq , isAsync : true ) ;
446
454
447
455
var scanResult = await SourceTable . DDBClient . ScanAsync ( scanReq , cancellationToken ) . ConfigureAwait ( false ) ;
448
- foreach ( var item in scanResult . Items )
456
+ if ( scanResult . Items != null )
449
457
{
450
- Document doc = SourceTable . FromAttributeMap ( item ) ;
451
- ret . Add ( doc ) ;
452
- if ( CollectResults )
458
+ foreach ( var item in scanResult . Items )
453
459
{
454
- Matches . Add ( doc ) ;
460
+ Document doc = SourceTable . FromAttributeMap ( item ) ;
461
+ ret . Add ( doc ) ;
462
+ if ( CollectResults )
463
+ {
464
+ Matches . Add ( doc ) ;
465
+ }
455
466
}
456
467
}
468
+
457
469
NextKey = scanResult . LastEvaluatedKey ;
458
470
if ( NextKey == null || NextKey . Count == 0 )
459
471
{
@@ -487,13 +499,16 @@ internal async Task<List<Document>> GetNextSetHelperAsync(CancellationToken canc
487
499
SourceTable . UpdateRequestUserAgentDetails ( queryReq , isAsync : true ) ;
488
500
489
501
var queryResult = await SourceTable . DDBClient . QueryAsync ( queryReq , cancellationToken ) . ConfigureAwait ( false ) ;
490
- foreach ( var item in queryResult . Items )
502
+ if ( queryResult . Items != null )
491
503
{
492
- Document doc = SourceTable . FromAttributeMap ( item ) ;
493
- ret . Add ( doc ) ;
494
- if ( CollectResults )
504
+ foreach ( var item in queryResult . Items )
495
505
{
496
- Matches . Add ( doc ) ;
506
+ Document doc = SourceTable . FromAttributeMap ( item ) ;
507
+ ret . Add ( doc ) ;
508
+ if ( CollectResults )
509
+ {
510
+ Matches . Add ( doc ) ;
511
+ }
497
512
}
498
513
}
499
514
NextKey = queryResult . LastEvaluatedKey ;
@@ -554,20 +569,25 @@ private static void SplitQueryFilter(Filter filter, Table targetTable, string in
554
569
QueryFilter queryFilter = filter as QueryFilter ;
555
570
if ( queryFilter == null ) throw new InvalidOperationException ( "Filter is not of type QueryFilter" ) ;
556
571
557
- keyConditions = new Dictionary < string , Condition > ( ) ;
558
- filterConditions = new Dictionary < string , Condition > ( ) ;
559
-
560
572
var conditions = filter . ToConditions ( targetTable ) ;
561
- foreach ( var kvp in conditions )
562
- {
563
- string attributeName = kvp . Key ;
564
- Condition condition = kvp . Value ;
573
+ keyConditions = null ;
574
+ filterConditions = null ;
565
575
566
- // depending on whether the attribute is key, place either in keyConditions or filterConditions
567
- if ( IsKeyAttribute ( targetTable , indexName , attributeName ) )
568
- keyConditions [ attributeName ] = condition ;
569
- else
570
- filterConditions [ attributeName ] = condition ;
576
+ if ( conditions . Count > 0 )
577
+ {
578
+ keyConditions = new Dictionary < string , Condition > ( ) ;
579
+ filterConditions = new Dictionary < string , Condition > ( ) ;
580
+ foreach ( var kvp in conditions )
581
+ {
582
+ string attributeName = kvp . Key ;
583
+ Condition condition = kvp . Value ;
584
+
585
+ // depending on whether the attribute is key, place either in keyConditions or filterConditions
586
+ if ( IsKeyAttribute ( targetTable , indexName , attributeName ) )
587
+ keyConditions [ attributeName ] = condition ;
588
+ else
589
+ filterConditions [ attributeName ] = condition ;
590
+ }
571
591
}
572
592
}
573
593
0 commit comments