-
Notifications
You must be signed in to change notification settings - Fork 351
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
Fix ArgumentException in ProjectPlanCompiler caused by missing materializerContext argument in dynamic calls #2535
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ namespace Microsoft.Test.OData.Tests.Client.AsynchronousTests | |
using System.Linq; | ||
using System.Net; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using Microsoft.OData.Client; | ||
using Microsoft.Test.OData.Services.TestServices; | ||
using Microsoft.Test.OData.Services.TestServices.AstoriaDefaultServiceReference; | ||
|
@@ -788,6 +789,24 @@ public void Linq_ProjectPropertiesFromEntityandExpandedEntity() | |
this.EnqueueTestComplete(); | ||
} | ||
|
||
[Fact] | ||
public async Task Linq_ProjectPropertiesFromEntityWithConditionalNullCheckOnExpandedEntity() | ||
{ | ||
var context = this.CreateWrappedContext<DefaultContainer>().Context; | ||
var query = context.Computer.Where(c => c.ComputerId == -10) | ||
.Select(c => new Computer | ||
{ | ||
ComputerId = c.ComputerId, | ||
ComputerDetail = c.ComputerDetail == null ? null : c.ComputerDetail, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is interesting, what does the ternary operator give us here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ternary operator here is used to force the |
||
}) as DataServiceQuery<Computer>; | ||
|
||
var result = await query.ExecuteAsync(); | ||
|
||
var computer = result.First(); | ||
Assert.Equal(-10, computer.ComputerId); | ||
Assert.Equal(-10, computer.ComputerDetail.ComputerDetailId); | ||
} | ||
|
||
/// <summary> | ||
/// LINQ query Project Name Stream Property | ||
/// </summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this test be the one that fails without your other changes? The LINQ query wasn't generating an expression with the materializer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was failing without my changes. It was throwing an
ArgumentException
because theProjectPlanCompiler
was generating a dynamic call toProjectionCheckValueForPathIsNull
without passing the requiredmaterializerContext
argument.