/// <summary>
            /// Visits an entry item.
            /// </summary>
            /// <param name="entry">The entry to visit.</param>
            protected override ODataPayloadElement VisitEntry(ODataEntry entry)
            {
                ODataPayloadElement payloadElement = base.VisitEntry(entry);
                ODataEntryPayloadOrderObjectModelAnnotation payloadOrderEntryAnnotation = entry.GetAnnotation <ODataEntryPayloadOrderObjectModelAnnotation>();

                if (payloadOrderEntryAnnotation != null)
                {
                    PayloadOrderODataPayloadElementAnnotation payloadOrderElementAnnotation = new PayloadOrderODataPayloadElementAnnotation();
                    payloadOrderElementAnnotation.PayloadItems.AddRange(payloadOrderEntryAnnotation.PayloadItems);
                    payloadElement.Add(payloadOrderElementAnnotation);
                }

                return(payloadElement);
            }
 /// <summary>
 /// Adds all properties found on a stream reference value to the payload order items.
 /// </summary>
 /// <param name="prefix">The prefix to add to all property names found.</param>
 /// <param name="streamReferenceValue">The stream reference value to inspect.</param>
 /// <param name="payloadOrderItems">The payload order items to add to, or null, if nothing should be done.</param>
 private static void AddStreamReferenceValuePayloadOrderItems(string prefix, ODataStreamReferenceValue streamReferenceValue, ODataEntryPayloadOrderObjectModelAnnotation payloadOrderItems)
 {
     if (payloadOrderItems == null) return;
     if (streamReferenceValue.ReadLink != null) payloadOrderItems.AddEntryProperty(prefix + "ReadLink");
     if (streamReferenceValue.ContentType != null) payloadOrderItems.AddEntryProperty(prefix + "ContentType");
     if (streamReferenceValue.EditLink != null) payloadOrderItems.AddEntryProperty(prefix + "EditLink");
     if (streamReferenceValue.ETag != null) payloadOrderItems.AddEntryProperty(prefix + "ETag");
 }
            /// <summary>
            /// Adds all properties found on an entry to the payload order items.
            /// </summary>
            /// <param name="entry">The entry to inspect.</param>
            /// <param name="payloadOrderItems">The payload order items to add to, or null, if nothing should be done.</param>
            private static void AddEntryPayloadOrderItems(ODataEntry entry, ODataEntryPayloadOrderObjectModelAnnotation payloadOrderItems)
            {
                if (payloadOrderItems == null) return;

                if (entry.Id != null) payloadOrderItems.AddEntryProperty("Id");
                if (entry.TypeName != null) payloadOrderItems.AddEntryProperty("TypeName");
                if (entry.EditLink != null) payloadOrderItems.AddEntryProperty("EditLink");
                if (entry.ReadLink != null) payloadOrderItems.AddEntryProperty("ReadLink");
                if (entry.ETag != null) payloadOrderItems.AddEntryProperty("ETag");
                if (entry.MediaResource != null)
                {
                    payloadOrderItems.AddEntryProperty("MediaResource");
                    AddStreamReferenceValuePayloadOrderItems("MediaResource_", entry.MediaResource, payloadOrderItems);
                }

                if (entry.Actions != null)
                {
                    foreach (ODataAction action in entry.Actions)
                    {
                        payloadOrderItems.AddAction(action);
                    }
                }

                if (entry.Functions != null)
                {
                    foreach (ODataFunction function in entry.Functions)
                    {
                        payloadOrderItems.AddFunction(function);
                    }
                }

                if (entry.Properties != null)
                {
                    foreach (ODataProperty property in entry.Properties)
                    {
                        payloadOrderItems.AddODataProperty(property);
                        ODataStreamReferenceValue streamPropertyValue = property.Value as ODataStreamReferenceValue;
                        if (streamPropertyValue != null)
                        {
                            AddStreamReferenceValuePayloadOrderItems(property.Name + "_", streamPropertyValue, payloadOrderItems);
                        }
                    }
                }
            }