@@ -697,7 +697,11 @@ internal void WriteDeltaComplexProperties(SelectExpandNode selectExpandNode,
697697 Contract . Assert ( resourceContext != null ) ;
698698 Contract . Assert ( writer != null ) ;
699699
700- IEnumerable < KeyValuePair < IEdmStructuralProperty , PathSelectItem > > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
700+ IDictionary < IEdmStructuralProperty , PathSelectItem > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
701+ if ( complexProperties == null )
702+ {
703+ return ;
704+ }
701705
702706 foreach ( KeyValuePair < IEdmStructuralProperty , PathSelectItem > complexProperty in complexProperties )
703707 {
@@ -781,7 +785,11 @@ internal async Task WriteDeltaComplexPropertiesAsync(SelectExpandNode selectExpa
781785 Contract . Assert ( resourceContext != null ) ;
782786 Contract . Assert ( writer != null ) ;
783787
784- IEnumerable < KeyValuePair < IEdmStructuralProperty , PathSelectItem > > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
788+ IDictionary < IEdmStructuralProperty , PathSelectItem > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
789+ if ( complexProperties == null )
790+ {
791+ return ;
792+ }
785793
786794 foreach ( KeyValuePair < IEdmStructuralProperty , PathSelectItem > complexProperty in complexProperties )
787795 {
@@ -1643,7 +1651,11 @@ private void WriteComplexProperties(SelectExpandNode selectExpandNode, ResourceC
16431651 Contract . Assert ( resourceContext != null ) ;
16441652 Contract . Assert ( writer != null ) ;
16451653
1646- IEnumerable < KeyValuePair < IEdmStructuralProperty , PathSelectItem > > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
1654+ IDictionary < IEdmStructuralProperty , PathSelectItem > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
1655+ if ( complexProperties == null )
1656+ {
1657+ return ;
1658+ }
16471659
16481660 foreach ( KeyValuePair < IEdmStructuralProperty , PathSelectItem > selectedComplex in complexProperties )
16491661 {
@@ -1666,7 +1678,11 @@ private async Task WriteComplexPropertiesAsync(SelectExpandNode selectExpandNode
16661678 Contract . Assert ( resourceContext != null ) ;
16671679 Contract . Assert ( writer != null ) ;
16681680
1669- IEnumerable < KeyValuePair < IEdmStructuralProperty , PathSelectItem > > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
1681+ IDictionary < IEdmStructuralProperty , PathSelectItem > complexProperties = GetPropertiesToWrite ( selectExpandNode , resourceContext ) ;
1682+ if ( complexProperties == null )
1683+ {
1684+ return ;
1685+ }
16701686
16711687 foreach ( KeyValuePair < IEdmStructuralProperty , PathSelectItem > selectedComplex in complexProperties )
16721688 {
@@ -1734,7 +1750,7 @@ private async Task WriteStreamPropertiesAsync(SelectExpandNode selectExpandNode,
17341750 }
17351751 }
17361752
1737- private IEnumerable < KeyValuePair < IEdmStructuralProperty , PathSelectItem > > GetPropertiesToWrite ( SelectExpandNode selectExpandNode , ResourceContext resourceContext )
1753+ private static IDictionary < IEdmStructuralProperty , PathSelectItem > GetPropertiesToWrite ( SelectExpandNode selectExpandNode , ResourceContext resourceContext )
17381754 {
17391755 IDictionary < IEdmStructuralProperty , PathSelectItem > complexProperties = selectExpandNode . SelectedComplexTypeProperties ;
17401756
@@ -1748,26 +1764,23 @@ private IEnumerable<KeyValuePair<IEdmStructuralProperty, PathSelectItem>> GetPro
17481764 changedProperties = deltaObject . GetChangedPropertyNames ( ) ;
17491765 }
17501766
1751- foreach ( KeyValuePair < IEdmStructuralProperty , PathSelectItem > complexProperty in complexProperties )
1767+ if ( changedProperties != null )
17521768 {
1753- if ( changedProperties == null || changedProperties . Contains ( complexProperty . Key . Name ) )
1769+ IDictionary < IEdmStructuralProperty , PathSelectItem > propertiesToReturn
1770+ = new Dictionary < IEdmStructuralProperty , PathSelectItem > ( ) ;
1771+ foreach ( KeyValuePair < IEdmStructuralProperty , PathSelectItem > complexProperty in complexProperties )
17541772 {
1755- IEdmTypeReference type = complexProperty . Key ? . Type ;
1756-
1757- if ( type != null && type . IsStructured ( ) && resourceContext . EdmModel != null )
1773+ if ( changedProperties . Contains ( complexProperty . Key . Name ) )
17581774 {
1759- Type clrType = EdmLibHelpers . GetClrType ( type . AsStructured ( ) , resourceContext . EdmModel ) ;
1760-
1761- if ( clrType != null && clrType == typeof ( ODataIdContainer ) )
1762- {
1763- continue ;
1764- }
1775+ propertiesToReturn [ complexProperty . Key ] = complexProperty . Value ;
17651776 }
1766-
1767- yield return complexProperty ;
17681777 }
1778+
1779+ return propertiesToReturn ;
17691780 }
17701781 }
1782+
1783+ return complexProperties ;
17711784 }
17721785
17731786 private IEnumerable < KeyValuePair < IEdmNavigationProperty , Type > > GetNavigationPropertiesToWrite ( SelectExpandNode selectExpandNode , ResourceContext resourceContext )
0 commit comments