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
77using System . Linq ;
88using Xtensive . Orm . Model ;
9+ using Xtensive . Core ;
910using Xtensive . Sql ;
1011using Xtensive . Sql . Dml ;
1112using 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