Skip to content

Commit d10a057

Browse files
committed
Remove list creation
1 parent e31a9a5 commit d10a057

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

src/NHibernate/Linq/Visitors/ParameterTypeLocator.cs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,32 +120,28 @@ private static HashSet<IType> GetCandidateTypes(
120120
IEnumerable<ConstantExpression> constantExpressions,
121121
ConstantTypeLocatorVisitor visitor)
122122
{
123-
var parameterRelatedExpressions = new List<Expression>();
123+
var candidateTypes = new HashSet<IType>();
124124
foreach (var expression in constantExpressions)
125125
{
126126
if (visitor.RelatedExpressions.TryGetValue(expression, out var relatedExpressions))
127127
{
128-
parameterRelatedExpressions.AddRange(relatedExpressions);
129-
}
130-
}
131-
132-
var candidateTypes = new HashSet<IType>();
133-
// In order to get the actual type we have to check first the related member expressions, as
134-
// an enum is translated in a numeric type when used in a BinaryExpression and also it can be mapped as string.
135-
// By getting the type from a related member expression we also get the correct length in case of StringType
136-
// or precision when having a DecimalType.
137-
foreach (var relatedExpression in parameterRelatedExpressions)
138-
{
139-
if (ExpressionsHelper.TryGetMappedType(sessionFactory, relatedExpression, out var candidateType, out _, out _, out _))
140-
{
141-
if (candidateType.IsAssociationType && visitor.SequenceSelectorExpressions.Contains(relatedExpression))
128+
// In order to get the actual type we have to check first the related member expressions, as
129+
// an enum is translated in a numeric type when used in a BinaryExpression and also it can be mapped as string.
130+
// By getting the type from a related member expression we also get the correct length in case of StringType
131+
// or precision when having a DecimalType.
132+
foreach (var relatedExpression in relatedExpressions)
142133
{
143-
var collection =
144-
(IQueryableCollection) ((IAssociationType) candidateType).GetAssociatedJoinable(sessionFactory);
145-
candidateType = collection.ElementType;
146-
}
134+
if (ExpressionsHelper.TryGetMappedType(sessionFactory, relatedExpression, out var candidateType, out _, out _, out _))
135+
{
136+
if (candidateType.IsAssociationType && visitor.SequenceSelectorExpressions.Contains(relatedExpression))
137+
{
138+
var collection = (IQueryableCollection) ((IAssociationType) candidateType).GetAssociatedJoinable(sessionFactory);
139+
candidateType = collection.ElementType;
140+
}
147141

148-
candidateTypes.Add(candidateType);
142+
candidateTypes.Add(candidateType);
143+
}
144+
}
149145
}
150146
}
151147

0 commit comments

Comments
 (0)