示例#1
0
        private D365ModelRepresentation BuildModelRepresentationLevel(PropertyInfo property)
        {
            var basicProperties = GetBasicProperties(property.PropertyType).Distinct().ToList();
            var typeProperties  = GetTypeProperties(property.PropertyType);

            var representation = new D365ModelRepresentation
            {
                RootExpandName = ExtractD365PropertyName(property),
                BaseProperties = basicProperties
            };

            foreach (var typeProperty in typeProperties)
            {
                representation.ExpandProperties.Add(BuildModelRepresentationLevel(typeProperty));
            }

            return(representation);
        }
示例#2
0
        private string BuildNestedLevelSelectAndExpand(D365ModelRepresentation representation)
        {
            var select = $"$select={representation.BaseProperties.ToDelimitedString(",")}";

            var individualExpands = new List <string>();

            foreach (var expandProp in representation.ExpandProperties)
            {
                var individualExpand = $"{expandProp.RootExpandName}({BuildNestedLevelSelectAndExpand(expandProp)})";
                individualExpands.Add(individualExpand);
            }

            if (!representation.ExpandProperties.Any())
            {
                return(select);
            }

            return($"{select};$expand={individualExpands.ToDelimitedString(",")}");
        }
示例#3
0
        /// <summary>
        /// Extracts the model representation of a class to enable building the OData Select and Expand clauses.
        /// </summary>
        /// <returns>The <see cref="D365ModelRepresentation"/> of a D365Model</returns>
        public D365ModelRepresentation ExtractModelRepresentation()
        {
            var basicProperties = GetBasicProperties(_type).Distinct().ToList();

            var levelOneTypeProperties = GetTypeProperties(_type);

            var modelRepresentation = new D365ModelRepresentation
            {
                RootExpandName = string.Empty,
                BaseProperties = basicProperties
            };

            foreach (var levelOneTypeProp in levelOneTypeProperties)
            {
                modelRepresentation.ExpandProperties.Add(BuildModelRepresentationLevel(levelOneTypeProp));
            }

            return(modelRepresentation);
        }