Exemplo n.º 1
0
        public string Compile(HandlerAccessor handlers, IndexInfo index)
        {
            var table = SqlDml.TableRef(CreateStubTable(index.ReflectedType.MappingName, index.Filter.Fields.Count));
            // Translation of ColumnRefs without alias seems broken, use original name as alias.
            var columns = index.Filter.Fields
                          .Select(field => field.Column.Name)
                          .Select((name, i) => SqlDml.ColumnRef(table.Columns[i], name))
                          .Cast <SqlExpression>()
                          .ToList();

            var processor = new ExpressionProcessor(index.Filter.Expression, handlers, null, columns);
            var fragment  = SqlDml.Fragment(processor.Translate());
            var result    = handlers.StorageDriver.Compile(fragment).GetCommandText();

            return(result);
        }