internal static class TypeExtensions
{
public static MemberInfo[] GetSelectedMembers(this Type parentType, List<string> selects)
{
if (selects == null || !selects.Any())
return parentType.GetValueTypeMembers();
return selects.Select(select => parentType.GetMemberInfo(select)).ToArray();
}
private static MemberInfo[] GetValueTypeMembers(this Type parentType)
{
if (parentType.IsList())
return new MemberInfo[] { };
return parentType.GetMemberInfos().Where
(
info => (info.MemberType == MemberTypes.Field || info.MemberType == MemberTypes.Property)
&& info.GetMemberType().IsLiteralType()
).ToArray();
}
The current implementation lacks the information required to distinguish between a navigation property and a complex type property. This information is however available in the EDM model.
Missing and wildcard selects should include all structural properties (see http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31361040), but the current implementation only includes literal types and therefore omits complex type properties.
The current implementation lacks the information required to distinguish between a navigation property and a complex type property. This information is however available in the EDM model.