Skip to content

Commit

Permalink
Merge pull request #54 from BlaiseD/master
Browse files Browse the repository at this point in the history
Fix for Issue #53 - InvalidOperationException mapping a string with Plus (+) operator
  • Loading branch information
BlaiseD authored Jan 3, 2020
2 parents f593fa2 + 6462472 commit d613dee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Authors>Jimmy Bogard</Authors>
<LangVersion>latest</LangVersion>
<VersionPrefix>3.0.5</VersionPrefix>
<VersionPrefix>3.0.6-preview01</VersionPrefix>
<WarningsAsErrors>true</WarningsAsErrors>
<NoWarn>$(NoWarn);1701;1702;1591</NoWarn>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ Expression DoVisitBinary(Expression newLeft, Expression newRight, Expression con
newLeft,
newRight,
node.IsLiftedToNull,
Expression.MakeBinary(node.NodeType, newLeft, newRight).Method
TypesChanged()
? Expression.MakeBinary(node.NodeType, newLeft, newRight).Method
: node.Method
);
}

return node;

bool TypesChanged() => newLeft.Type != node.Left.Type || newRight.Type != node.Right.Type;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ public void Map_object_type_change_again()
Assert.True(users.Count == 0);
}

[Fact]
public void Uses_the_correct_Add_expression_when_mapping_string_plus_operator()
{
//Arrange
Expression<Func<UserModel, bool>> selection = s => s.FullName + "FFF" == "";

//Act
Expression<Func<User, bool>> selectionMapped = mapper.MapExpression<Expression<Func<User, bool>>>(selection);
List<User> users = Users.Where(selectionMapped).ToList();

//Assert
Assert.True(users.Count == 0);
}

[Fact]
public void Map__object_including_child_and_grandchild()
{
Expand Down

0 comments on commit d613dee

Please sign in to comment.