Skip to content

Commit 01615de

Browse files
committed
PartialIndexFilterCompiler: Small code improvements
1 parent 8ff5778 commit 01615de

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Orm/Xtensive.Orm/Orm/Providers/PartialIndexFilterCompiler.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
// Copyright (C) 2013 Xtensive LLC
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-2024 Xtensive LLC
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
55
// Created: 2013.07.18
66

77
using System.Linq;
88
using Xtensive.Orm.Model;
9+
using Xtensive.Core;
910
using Xtensive.Sql;
1011
using Xtensive.Sql.Dml;
1112
using Xtensive.Sql.Model;
@@ -16,13 +17,16 @@ internal sealed class PartialIndexFilterCompiler
1617
{
1718
public string Compile(HandlerAccessor handlers, IndexInfo index)
1819
{
19-
var table = SqlDml.TableRef(CreateStubTable(index.ReflectedType.MappingName, index.Filter.Fields.Count));
20+
var filter = index.Filter;
21+
var fieldsCount = filter.Fields.Count;
22+
23+
var table = SqlDml.TableRef(CreateStubTable(index.ReflectedType.MappingName, fieldsCount));
2024
// Translation of ColumnRefs without alias seems broken, use original name as alias.
21-
var columns = index.Filter.Fields
25+
var columns = filter.Fields
2226
.Select(field => field.Column.Name)
2327
.Select((name, i) => SqlDml.ColumnRef(table.Columns[i], name))
2428
.Cast<SqlExpression>()
25-
.ToList();
29+
.ToList(fieldsCount);
2630

2731
var processor = new ExpressionProcessor(filter.Expression, handlers, null, true, columns);
2832
var fragment = SqlDml.Fragment(processor.Translate());

0 commit comments

Comments
 (0)