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

InMemory: Read nullable value for derived properties #25968

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ public InMemoryQueryExpression(IEntityType entityType)

foreach (var property in derivedEntityType.GetDeclaredProperties())
{
// We read nullable value from property of derived type since it could be null.
var typeToRead = property.ClrType.MakeNullable();
var propertyExpression = Condition(
entityCheck,
CreateReadValueExpression(property.ClrType, property.GetIndex(), property),
Default(property.ClrType));
CreateReadValueExpression(typeToRead, property.GetIndex(), property),
Default(typeToRead));

selectorExpressions.Add(propertyExpression);
var readExpression = CreateReadValueExpression(property.ClrType, selectorExpressions.Count - 1, property);
var readExpression = CreateReadValueExpression(propertyExpression.Type, selectorExpressions.Count - 1, property);
propertyExpressionsMap[property] = readExpression;
_projectionMappingExpressions.Add(readExpression);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,5 @@ public override async Task Projecting_some_properties_as_well_as_correlated_coll

Assert.Equal(InMemoryStrings.DistinctOnSubqueryNotSupported, message);
}

[ConditionalTheory(Skip = "Issue #25735")]
public override Task Project_navigation_defined_on_derived_from_entity_with_inheritance_using_soft_cast(bool async)
{
return base.Project_navigation_defined_on_derived_from_entity_with_inheritance_using_soft_cast(async);
}
}
}