예제 #1
0
        internal override QueryInfo[] BuildQuery(Expression query, SqlNodeAnnotations annotations)
        {
            CheckDispose();
            query = Funcletizer.Funcletize(query);
            var converter = new MySqlQueryConverter(services, typeProvider, translator, sqlFactory)
            {
                ConverterStrategy = ConverterStrategy.CanOutputFromInsert | ConverterStrategy.CanUseJoinOn |
                                    ConverterStrategy.CanUseOuterApply | ConverterStrategy.SkipWithRowNumber
            };
            SqlNode node       = converter.ConvertOuter(query);
            var     queryInfos = BuildQuery(GetResultShape(query), GetResultType(query), node, null, annotations);
            var     formatter  = new MySqlFormatter(this);

            for (int i = 0; i < queryInfos.Length; i++)
            {
                var queryInfo = queryInfos[i];
                queryInfo.CommandText = formatter.Format(queryInfo.Query);
            }
            return(queryInfos);
        }
예제 #2
0
        internal override ICompiledSubQuery CompileSubQuery(SqlNode query, Type elementType, ReadOnlyCollection <SqlParameter> parameters)
        {
            query = SqlDuplicator.Copy(query);
            var annotations = new SqlNodeAnnotations();

            QueryInfo[] queries   = BuildQuery(ResultShape.Sequence, TypeSystem.GetSequenceType(elementType), query, parameters, annotations);
            QueryInfo   queryInfo = queries[0];

            ICompiledSubQuery[] subQueries = this.CompileSubQueries(queryInfo.Query);
            var formatter = new MySqlFormatter(this);

            for (int i = 0; i < subQueries.Length; i++)
            {
                var subQuery = (CompiledSubQuery)subQueries[i];
                subQuery.QueryInfo.CommandText = formatter.Format(subQuery.QueryInfo.Query);
            }
            IObjectReaderFactory readerFactory = this.GetReaderFactory(queryInfo.Query, elementType);

            CheckSqlCompatibility(queries, annotations);
            return(new CompiledSubQuery(queryInfo, readerFactory, parameters, subQueries, connectionString, this));
        }