diff --git a/PanoramicData.OData.Client/MemberPathResolver.cs b/PanoramicData.OData.Client/MemberPathResolver.cs index 5f904c3..b7ec547 100644 --- a/PanoramicData.OData.Client/MemberPathResolver.cs +++ b/PanoramicData.OData.Client/MemberPathResolver.cs @@ -146,6 +146,23 @@ internal static bool TryGetPathLoose(Expression expression, out string path) return false; } + /// + /// Well-known scalar (non-navigation) reference/value types that aren't caught by + /// or . + /// + private static readonly HashSet _scalarTypes = + [ + typeof(string), + typeof(DateTime), + typeof(DateTimeOffset), + typeof(DateOnly), + typeof(TimeOnly), + typeof(TimeSpan), + typeof(Guid), + typeof(decimal), + typeof(byte[]) + ]; + /// /// Determines if a property is a navigation property (vs a scalar property). /// Navigation properties are entity references or collections of entities. @@ -162,40 +179,14 @@ internal static bool IsNavigationProperty(PropertyInfo property) propertyType = underlyingType; } - // Primitives are scalar - if (propertyType.IsPrimitive) - { - return false; - } - - // Common scalar types - if (propertyType == typeof(string) || - propertyType == typeof(DateTime) || - propertyType == typeof(DateTimeOffset) || - propertyType == typeof(DateOnly) || - propertyType == typeof(TimeOnly) || - propertyType == typeof(TimeSpan) || - propertyType == typeof(Guid) || - propertyType == typeof(decimal)) - { - return false; - } - - // Enums are scalar - if (propertyType.IsEnum) - { - return false; - } - - // byte[] is scalar (used for binary data) - if (propertyType == typeof(byte[])) + // Primitives, enums, and well-known scalar types (string, dates, guid, decimal, byte[]) are scalar + if (propertyType.IsPrimitive || propertyType.IsEnum || _scalarTypes.Contains(propertyType)) { return false; } - // Collections of entities are navigation properties (but not string which is IEnumerable) - if (typeof(System.Collections.IEnumerable).IsAssignableFrom(propertyType) && - propertyType != typeof(string)) + // Collections are navigation properties (string, the one scalar IEnumerable, is already handled above) + if (typeof(System.Collections.IEnumerable).IsAssignableFrom(propertyType)) { return true; }