/// <summary> /// Constrói o resultado com as informações que serão processadas. /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public override QueryReturnInfo BuildResultInfo <T>(GDA.Interfaces.IProviderConfiguration configuration) { if (string.IsNullOrEmpty(_commandText)) { throw new QueryException("Command text not informed."); } var query = _commandText; if (!string.IsNullOrEmpty(Order)) { var orderByIndex = query.LastIndexOf("ORDER BY"); if (orderByIndex >= 0) { query = query.Substring(0, orderByIndex); } query += " ORDER BY " + Order; } var mapping = MappingManager.GetMappers <T>(null, null); var selectProps = new List <Mapper>(mapping); if (!string.IsNullOrEmpty(_selectProperties) && _selectProperties != "*") { List <string> functions = new List <string>(); Parser p = new Parser(new Lexer(_selectProperties)); SelectPart sp = p.ExecuteSelectPart(); selectProps = new List <Mapper>(sp.SelectionExpressions.Count); foreach (SelectExpression se in sp.SelectionExpressions) { if (se.ColumnName.Type == GDA.Sql.InterpreterExpression.Enums.SqlExpressionType.Column) { Column col = se.Column; foreach (Mapper mp in mapping) { if (string.Compare(se.ColumnName.Value.Text, mp.PropertyMapperName, true) == 0 && (mp.Direction == DirectionParameter.Input || mp.Direction == DirectionParameter.InputOutput || mp.Direction == DirectionParameter.OutputOnlyInsert)) { if (!selectProps.Exists(f => f.PropertyMapperName == mp.PropertyMapperName)) { selectProps.Add(mp); } } } if (col.Name == "*") { throw new GDAException("Invalid expression {0}", se.ColumnName.Value.Text); } } else if (se.ColumnName.Type == GDA.Sql.InterpreterExpression.Enums.SqlExpressionType.Function) { throw new QueryException("NativeQuery not support function in select part"); } } } return(new QueryReturnInfo(query, this.Parameters, selectProps)); }
/// <summary> /// Constrói as informações para o resultado da consulta. /// </summary> /// <typeparam name="T">Tipo de dados que será tratado na consulta.</typeparam> /// <returns>Consulta SQL gerada.</returns> public abstract QueryReturnInfo BuildResultInfo <T>(GDA.Interfaces.IProviderConfiguration configuration);
/// <summary> /// Constrói o resultado com as informações que serão processadas. /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public override QueryReturnInfo BuildResultInfo <T>(GDA.Interfaces.IProviderConfiguration configuration) { return(new QueryReturnInfo(Parser2(configuration.Provider, parameters), parameters, MappingManager.GetMappers <T>(null, null))); }