Skip to content

Commit ad2daf4

Browse files
committed
QueryTranslationResult moves List creation to the caller
this allows to create List more efficiently
1 parent 4c3fa06 commit ad2daf4

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryBuilder.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2012-2020 Xtensive LLC.
1+
// Copyright (C) 2012-2020 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
@@ -47,9 +47,14 @@ public QueryTranslationResult TranslateQuery<TResult>(IQueryable<TResult> query)
4747

4848
var request = sqlProvider.Request;
4949

50-
return new QueryTranslationResult(
51-
request.Statement,
52-
request.ParameterBindings.Select(b => new QueryParameterBinding(b)));
50+
if (request.ParameterBindings is ICollection<Providers.QueryParameterBinding> bindingCollection) {
51+
return new QueryTranslationResult(
52+
request.Statement,
53+
bindingCollection.SelectToList(b => new QueryParameterBinding(b)));
54+
}
55+
else
56+
return new QueryTranslationResult(request.Statement,
57+
request.ParameterBindings.Select(b => new QueryParameterBinding(b)).ToList());
5358
}
5459

5560
/// <summary>

Orm/Xtensive.Orm/Orm/Services/QueryBuilding/QueryTranslationResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2012 Xtensive LLC.
1+
// Copyright (C) 2012 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Denis Krjuchkov
@@ -27,10 +27,10 @@ public sealed class QueryTranslationResult
2727

2828
// Constructors
2929

30-
internal QueryTranslationResult(ISqlCompileUnit query, IEnumerable<QueryParameterBinding> bindings)
30+
internal QueryTranslationResult(ISqlCompileUnit query, IList<QueryParameterBinding> bindings)
3131
{
3232
Query = query;
33-
ParameterBindings = bindings.ToList();
33+
ParameterBindings = bindings;
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)