コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: DapperExtensions.cs プロジェクト: singlag888/NewWeb
 /// <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));
 }
コード例 #3
0
        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));
        }
コード例 #4
0
 public IMultipleResultReader GetMultiple(GetMultiplePredicate predicate, int?commandTimeout)
 {
     return(_dapper.GetMultiple(Connection, predicate, _transaction, commandTimeout));
 }