@@ -30,16 +30,19 @@ public DataverseEntityMapper(ILiquidDataverse adapter) : base(nameof(DataverseEn
3030 ///<inheritdoc/>
3131 protected override async Task < Entity > MapImpl ( string jsonString , string ? entityName = null )
3232 {
33- if ( entityName == null ) { throw new ArgumentNullException ( nameof ( entityName ) ) ; }
33+ ArgumentNullException . ThrowIfNull ( entityName ) ;
3434
3535 var entityAttributes = await GetEntityAttributes ( entityName ) ;
3636
37+ if ( entityAttributes == null )
38+ throw new ArgumentNullException ( nameof ( entityAttributes ) , $ "Entity { entityName } not found.") ;
39+
3740 var entity = JsonToEntity ( entityAttributes , jsonString ) ;
3841
3942 return entity ;
4043 }
4144
42- private async Task < List < AttributeMetadata > > GetEntityAttributes ( string entityName , List < string > ? noMappingFields = null )
45+ private async Task < List < AttributeMetadata > ? > GetEntityAttributes ( string entityName , List < string > ? noMappingFields = null )
4346 {
4447 var entityMetadata = _entitiesMetadata . FirstOrDefault ( x => x . Key == entityName ) . Value ;
4548
@@ -67,15 +70,21 @@ private async Task<List<AttributeMetadata>> GetEntityAttributes(string entityNam
6770
6871 return listAttributes ;
6972 }
70- private Entity JsonToEntity ( List < AttributeMetadata > attributes , string values )
73+ private static Entity JsonToEntity ( List < AttributeMetadata > attributes , string values )
7174 {
7275 var entidade = new Entity ( ) ;
7376 var valuesObject = JsonConvert . DeserializeObject < JObject > ( values ) ;
77+ if ( valuesObject == null )
78+ return entidade ;
7479
7580 foreach ( var atrribute in attributes )
7681 {
7782 var logicalName = atrribute . LogicalName . ToUpper ( ) ;
78- if ( valuesObject [ logicalName ] != null && valuesObject [ logicalName ] . ToString ( ) != "" )
83+
84+ if ( valuesObject [ logicalName ] == null )
85+ continue ;
86+
87+ if ( valuesObject [ logicalName ] . ToString ( ) != "" )
7988 {
8089
8190 switch ( atrribute . AttributeType . ToString ( ) )
0 commit comments