From cfd9ae0427b149dee68e7e450b961a4c0923c7a0 Mon Sep 17 00:00:00 2001 From: Anas Ismail Khan Date: Thu, 25 Jul 2024 21:26:52 +0500 Subject: [PATCH] Added DateOnly and put #if_NET8 around the if block. Also removed the weird lines from the csproj --- .../Query/Expressions/SelectExpandBinder.cs | 5 ++++- .../Microsoft.AspNetCore.OData.E2E.Tests.csproj | 16 ++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.OData/Query/Expressions/SelectExpandBinder.cs b/src/Microsoft.AspNetCore.OData/Query/Expressions/SelectExpandBinder.cs index 6feb90987..f2f69e953 100644 --- a/src/Microsoft.AspNetCore.OData/Query/Expressions/SelectExpandBinder.cs +++ b/src/Microsoft.AspNetCore.OData/Query/Expressions/SelectExpandBinder.cs @@ -100,11 +100,13 @@ internal Expression ProjectAsWrapper(QueryBinderContext context, Expression sour bool isCollection, isPrimitiveCollection = false; isCollection = TypeHelper.IsCollection(source.Type, out elementType); + #if NET8_0_OR_GREATER if (isCollection) { if (elementType == typeof(string) || elementType == typeof(Uri) || elementType == typeof(DateTime) + || elementType == typeof(DateOnly) || elementType == typeof(DateTimeOffset) || elementType == typeof(int) || elementType == typeof(uint) @@ -124,6 +126,7 @@ internal Expression ProjectAsWrapper(QueryBinderContext context, Expression sour isPrimitiveCollection = true; } } + #endif QueryBinderContext subContext = new QueryBinderContext(context, context.QuerySettings, elementType); if (computeClause != null && IsAvailableODataQueryOption(context.QuerySettings, AllowedQueryOptions.Compute)) { @@ -139,7 +142,7 @@ internal Expression ProjectAsWrapper(QueryBinderContext context, Expression sour && !isPrimitiveCollection ) { - + // new CollectionWrapper { Instance = source.Select(s => new Wrapper { ... }) }; return ProjectCollection(subContext, source, elementType, selectExpandClause, structuredType, navigationSource, orderByClause, topOption, diff --git a/test/Microsoft.AspNetCore.OData.E2E.Tests/Microsoft.AspNetCore.OData.E2E.Tests.csproj b/test/Microsoft.AspNetCore.OData.E2E.Tests/Microsoft.AspNetCore.OData.E2E.Tests.csproj index 734aa27c1..c3c4ba998 100644 --- a/test/Microsoft.AspNetCore.OData.E2E.Tests/Microsoft.AspNetCore.OData.E2E.Tests.csproj +++ b/test/Microsoft.AspNetCore.OData.E2E.Tests/Microsoft.AspNetCore.OData.E2E.Tests.csproj @@ -15,16 +15,15 @@ - - - - - - - + + + + + + @@ -54,7 +53,4 @@ - - - \ No newline at end of file