Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,10 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
if (methodCallExpression.Object != null
&& @object!.Type.IsNullableType()
&& methodCallExpression.Method.Name != nameof(Nullable<int>.GetValueOrDefault)
&& (!@object!.Type.IsNullableValueType()
|| methodCallExpression.Method.Name != nameof(Nullable<int>.ToString)))
&& !(@object!.Type.IsNullableValueType()
&& methodCallExpression.Method.Name == nameof(Nullable<int>.ToString)
Comment thread
cincuranet marked this conversation as resolved.
&& methodCallExpression.Method.DeclaringType != null
&& methodCallExpression.Method.DeclaringType.IsNullableType()))
{
var result = (Expression)methodCallExpression.Update(
Expression.Convert(@object, methodCallExpression.Object.Type),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,28 @@ public override Task Join_include_conditional(bool async)
// Right join not supported in InMemory
public override Task Correlated_collections_on_RightJoin_with_predicate(bool async)
=> AssertTranslationFailed(() => base.Correlated_collections_on_RightJoin_with_predicate(async));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Select_ToString_on_non_nullable_property_of_an_optional_entity(bool async)
{
return AssertQuery(
async,
ss => ss.Set<CogTag>().Select(x => new
{
Id = x.Id,
SquadIdString = x.Gear.SquadId.ToString()
}),
ss => ss.Set<CogTag>().Select(x => new
{
Id = x.Id,
SquadIdString = x.Gear == null ? null : x.Gear.SquadId.ToString()
}),
elementSorter: e => e.Id,
elementAsserter: (e, a) =>
{
AssertEqual(e.Id, a.Id);
AssertEqual(e.SquadIdString, a.SquadIdString);
});
}
}