@@ -446,16 +446,20 @@ public static void EnrichResponse(IQueryable<SCIMRepresentationAttribute> attrib
446
446
switch ( representationAttr . SchemaAttribute . Type )
447
447
{
448
448
case SCIMSchemaAttributeTypes . STRING :
449
- jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesString ) : representationAttr . ValuesString . First ( ) ) ;
449
+ if ( representationAttr . ValuesString != null && representationAttr . ValuesString . Any ( ) )
450
+ jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesString ) : representationAttr . ValuesString . First ( ) ) ;
450
451
break ;
451
452
case SCIMSchemaAttributeTypes . BOOLEAN :
452
- jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesBoolean ) : representationAttr . ValuesBoolean . First ( ) ) ;
453
+ if ( representationAttr . ValuesBoolean != null && representationAttr . ValuesBoolean . Any ( ) )
454
+ jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesBoolean ) : representationAttr . ValuesBoolean . First ( ) ) ;
453
455
break ;
454
456
case SCIMSchemaAttributeTypes . INTEGER :
455
- jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesInteger ) : representationAttr . ValuesInteger . First ( ) ) ;
457
+ if ( representationAttr . ValuesInteger != null && representationAttr . ValuesInteger . Any ( ) )
458
+ jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesInteger ) : representationAttr . ValuesInteger . First ( ) ) ;
456
459
break ;
457
460
case SCIMSchemaAttributeTypes . DATETIME :
458
- jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesDateTime ) : representationAttr . ValuesDateTime . First ( ) ) ;
461
+ if ( representationAttr . ValuesDateTime != null && representationAttr . ValuesDateTime . Any ( ) )
462
+ jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesDateTime ) : representationAttr . ValuesDateTime . First ( ) ) ;
459
463
break ;
460
464
case SCIMSchemaAttributeTypes . COMPLEX :
461
465
if ( representationAttr . SchemaAttribute . MultiValued == false )
@@ -478,10 +482,12 @@ public static void EnrichResponse(IQueryable<SCIMRepresentationAttribute> attrib
478
482
}
479
483
break ;
480
484
case SCIMSchemaAttributeTypes . DECIMAL :
481
- jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesDecimal ) : representationAttr . ValuesDecimal . First ( ) ) ;
485
+ if ( representationAttr . ValuesDecimal != null && representationAttr . ValuesDecimal . Any ( ) )
486
+ jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesDecimal ) : representationAttr . ValuesDecimal . First ( ) ) ;
482
487
break ;
483
488
case SCIMSchemaAttributeTypes . BINARY :
484
- jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesBinary . Select ( _ => Convert . ToBase64String ( _ ) ) ) : Convert . ToBase64String ( representationAttr . ValuesBinary . First ( ) ) ) ;
489
+ if ( representationAttr . ValuesBinary != null && representationAttr . ValuesBinary . Any ( ) )
490
+ jObj . Add ( representationAttr . SchemaAttribute . Name , representationAttr . SchemaAttribute . MultiValued ? ( JToken ) new JArray ( representationAttr . ValuesBinary . Select ( _ => Convert . ToBase64String ( _ ) ) ) : Convert . ToBase64String ( representationAttr . ValuesBinary . First ( ) ) ) ;
485
491
break ;
486
492
}
487
493
}
0 commit comments