Skip to content

Commit 3d0c6ae

Browse files
committed
Cleanup
1 parent 2d806b0 commit 3d0c6ae

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/NHibernate/Linq/DmlExpressionRewriter.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,19 @@ public static Expression PrepareExpressionFromAnonymous<TSource>(Expression sour
122122
throw new ArgumentNullException(nameof(expression));
123123

124124
// Anonymous initializations are not implemented as member initialization but as plain constructor call, potentially wrapped in a Convert expression
125-
var newExpression = UnwrapConvert(expression.Body) as NewExpression ??
125+
var newExpression = UnwrapConvertExpression(expression.Body) as NewExpression ??
126126
throw new ArgumentException("The expression must be an anonymous initialization, e.g. x => new { Name = x.Name, Age = x.Age + 5 }");
127127

128128
var instance = new DmlExpressionRewriter(expression.Parameters);
129129
instance.AddSettersFromAnonymousConstructor(newExpression, "");
130130
return PrepareExpression<TSource>(sourceExpression, instance._assignments);
131131
}
132132

133-
private static Expression UnwrapConvert(Expression expression)
133+
private static Expression UnwrapConvertExpression(Expression expression)
134134
{
135-
if (expression is UnaryExpression unaryExpression &&
136-
unaryExpression.NodeType is ExpressionType.Convert or ExpressionType.ConvertChecked)
135+
if (expression is UnaryExpression ue && ue.NodeType == ExpressionType.Convert)
137136
{
138-
return unaryExpression.Operand;
137+
return ue.Operand;
139138
}
140139

141140
return expression;

0 commit comments

Comments
 (0)