Hi, I would like to start a discussion regarding the $levels implementation again. I had a look at the code and found some points where the current implementation has some bugs. I would also like to propose changing the cycle detection.
Bug/Improvement: If a navigation property has an expand with $levels then only the same navigation property must be expanded for the children. Currently all navigation properties of the child are expanded. The ExpandSelectHelper getExpandAll and isExpandAll methods are virtually the same. We should not need such code duplication. ODataMetadata=full does not work with expanded navigation properties and $levels. The cycle detection runs even if the navigation property is not expanded. I can change that to be more efficient. Improvement regarding the cycle detection: I would propose to remove the detection based on the OData Entity ID because this ID is not mandatory in the OData-Metadata minimal and none case. In both cases we now need this ID even if it is not part of the payload but only if $levels is specified. This is also an incompatible change to the behavior to the 4.2.0 version which I missed. I would rather use the object reference as a base for the comparison or the equals method of the ODataEntity object. This way we do not require more information passed to the serializer than absolutely necessary. Does anyone object to the points mentioned above? If not I would go ahead and implement the changes. Best Regards, Christian
