Skip to content

Commit

Permalink
remove flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilshod Komilov committed Sep 13, 2021
1 parent 11ad626 commit 119f2a9
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,8 @@ internal Expression ProjectElement(Expression source, SelectExpandClause selectE
LinqParameterContainer.Parameterize(typeof(string), _modelID) :
Expression.Constant(_modelID);
wrapperTypeMemberAssignments.Add(Expression.Bind(wrapperProperty, wrapperPropertyValueExpression));
bool instanseOfWrapperClassWasSet = false;
if (IsSelectAll(selectExpandClause))
{
instanseOfWrapperClassWasSet = true;
// Initialize property 'Instance' on the wrapper class
wrapperProperty = wrapperType.GetProperty("Instance");
wrapperTypeMemberAssignments.Add(Expression.Bind(wrapperProperty, source));
Expand Down Expand Up @@ -351,10 +349,7 @@ internal Expression ProjectElement(Expression source, SelectExpandClause selectE
Type wrapperGenericType = GetWrapperGenericType(isInstancePropertySet, isTypeNamePropertySet, isContainerPropertySet);
wrapperType = wrapperGenericType.MakeGenericType(elementType);

if (instanseOfWrapperClassWasSet)
return Expression.MemberInit(Expression.New(wrapperType), wrapperTypeMemberAssignments);
ConstructorInfo constructorWithInstanse = wrapperType.GetConstructors().Single(c => c.GetParameters().Length == 1);
return Expression.MemberInit(Expression.New(constructorWithInstanse, source), wrapperTypeMemberAssignments);
return Expression.MemberInit(Expression.New(wrapperType), wrapperTypeMemberAssignments);
}

/// <summary>
Expand Down

0 comments on commit 119f2a9

Please sign in to comment.