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

Version 3.27.0: CosmosLinqExtensions.ToFeedIterator() throw NullReferenceException when query predict has inline static member #3188

Closed
lifeglam opened this issue May 12, 2022 · 4 comments · Fixed by #3190
Labels
bug Something isn't working LINQ

Comments

@lifeglam
Copy link

Version 3.27.0: CosmosLinqExtensions.ToFeedIterator() throw NullReferenceException when query predict has inline static member.

To Reproduce
Below code DOES NOT work on 3.27.0 (but works on 3.26.2):

var queryable = _remoteContainer.GetItemLinqQueryable(true, null, null);
Expression<Func<T, bool>> predict = (x => x.CreationTime < DateTime.UtcNow);
var query = queryable.Where(predict);
var iterator = query.ToFeedIterator();

Below code works on 3.27.0:

var queryable = _remoteContainer.GetItemLinqQueryable(true, null, null);
var dateTime = DateTime.UtcNow;
Expression<Func<T, bool>> predict = (x => x.CreationTime < dateTime);
var query = queryable.Where(predict);
var iterator = query.ToFeedIterator();

Expected behavior
ToFeedIterator() call successfully

Actual behavior
ToFeedIterator() throw NullReferenceException

Environment summary
SDK Version: 3.27.0 (3.26.2 works)

Additional context
Per release note https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md
Might caused by Performance: Adds a LINQ optimization for member access in LINQ-to-SQL #2924

@j82w j82w added the bug Something isn't working label May 12, 2022
@j82w
Copy link
Contributor

j82w commented May 12, 2022

@notheotherben and @khdang can you take a look?

@j82w
Copy link
Contributor

j82w commented May 12, 2022

@lifeglam can you provide the full exception with stack trace of the null ref?

@j82w j82w added the LINQ label May 12, 2022
notheotherben added a commit to notheotherben/azure-cosmos-dotnet-v3 that referenced this issue May 12, 2022
… LINQ expression which performs static field or property access (fixes Azure#3188)
@notheotherben
Copy link
Member

Was able to reproduce and fix this, you'll find the associated change in #3190 and please let me know if you'd like to see anything else covered there.

j82w pushed a commit that referenced this issue May 12, 2022
…r a LINQ expression which performs static field or property access (fixes #3188) (#3190)

This PR should fix the issue raised in #3188 in which attempts to access a static field or property (such as DateTime.UtcNow) within a LINQ-to-SQL expression will result in a NullReferenceException. It does so by correctly handling the presence of a null member expression when evaluating field and property access.
@j82w
Copy link
Contributor

j82w commented May 25, 2022

@lifeglam please upgrade to 3.27.1 which contains the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LINQ
Projects
None yet
3 participants