Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to query nullable fields via LINQ expressions #1531

Open
1 task done
SPWizard01 opened this issue Sep 15, 2024 · 0 comments
Open
1 task done

Unable to query nullable fields via LINQ expressions #1531

SPWizard01 opened this issue Sep 15, 2024 · 0 comments

Comments

@SPWizard01
Copy link

SPWizard01 commented Sep 15, 2024

Category

  • Bug

Describe the bug

i.e. you want to query Site Pages for anything that has been published straight away or scheduled time is less than now will throw an error:

System.NotSupportedException: Node of type Equal of expression ((c.Values.get_Item("OData__PublishStartDate") As Nullable`1) == null) is not supported

Steps to reproduce

this works:

            var items = await myList.Items.Where(c =>
                (c.Values["OData__PublishStartDate"] as DateTimeOffset?) <= now
            ).ToListAsync();

this does not:

            var items = await myList.Items.Where(c =>
                (c.Values["OData__PublishStartDate"] as DateTimeOffset?) <= now ||
                (c.Values["OData__PublishStartDate"] as DateTimeOffset?) == null
            ).ToListAsync();

Expected behavior

the OData Query that is produced should be

OData__PublishStartDate le datetime'2024-09-15T05:18:54Z' or OData__PublishStartDate eq null

Environment details (development & target environment)

  • SDK version: 1.14
  • OS: Win 11
  • SDK used in: ASP.Net Web app
  • Framework: .NET Core v8
  • Browser(s): Chromium Edge Latest
  • Tooling: Visual Studio 2022

Additional context

In my opinion the problem is here:

if (filterField != null && filterValue != null)

I am not sure if null check should be performed on the value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant