/// <summary> /// 根据查询条件获取复合结果 /// </summary> /// <param name="predicate">查询条件</param> /// <param name="commandTimeout">超时时间</param> /// <returns></returns> public IMultipleResultReader GetMultiple(GetMultiplePredicate predicate, int?commandTimeout) { return(_dapper.GetMultiple(Connection, predicate, _transaction, commandTimeout)); }
protected GridReaderResultReader GetMultipleByBatch(IDbConnection connection, GetMultiplePredicate predicate, IDbTransaction transaction, int?commandTimeout) { Dictionary <string, object> parameters = new Dictionary <string, object>(); StringBuilder sql = new StringBuilder(); foreach (var item in predicate.Items) { IClassMapper classMap = SqlGenerator.Configuration.GetMap(item.Type); IPredicate itemPredicate = item.Value as IPredicate; if (itemPredicate == null && item.Value != null) { itemPredicate = GetPredicate(classMap, item.Value); } sql.AppendLine(SqlGenerator.Select(classMap, itemPredicate, item.Sort, parameters) + SqlGenerator.Configuration.Dialect.BatchSeperator); } DynamicParameters dynamicParameters = new DynamicParameters(); foreach (var parameter in parameters) { dynamicParameters.Add(parameter.Key, parameter.Value); } SqlMapper.GridReader grid = connection.QueryMultiple(sql.ToString(), dynamicParameters, transaction, commandTimeout, CommandType.Text); return(new GridReaderResultReader(grid)); }
protected SequenceReaderResultReader GetMultipleBySequence(IDbConnection connection, GetMultiplePredicate predicate, IDbTransaction transaction, int?commandTimeout) { IList <SqlMapper.GridReader> items = new List <SqlMapper.GridReader>(); foreach (var item in predicate.Items) { Dictionary <string, object> parameters = new Dictionary <string, object>(); IClassMapper classMap = SqlGenerator.Configuration.GetMap(item.Type); IPredicate itemPredicate = item.Value as IPredicate; if (itemPredicate == null && item.Value != null) { itemPredicate = GetPredicate(classMap, item.Value); } string sql = SqlGenerator.Select(classMap, itemPredicate, item.Sort, parameters); DynamicParameters dynamicParameters = new DynamicParameters(); foreach (var parameter in parameters) { dynamicParameters.Add(parameter.Key, parameter.Value); } SqlMapper.GridReader queryResult = connection.QueryMultiple(sql, dynamicParameters, transaction, commandTimeout, CommandType.Text); items.Add(queryResult); } return(new SequenceReaderResultReader(items)); }
/// <summary> /// Executes a select query for multiple objects, returning IMultipleResultReader for each predicate. /// </summary> public static IMultipleResultReader GetMultiple(this IDbConnection connection, GetMultiplePredicate predicate, IDbTransaction transaction = null, int?commandTimeout = null) { return(Instance.GetMultiple(connection, predicate, transaction, commandTimeout)); }