示例#1
0
        /// <summary>
        /// Get an IEnumerable that will execute the specified query when enumerated
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query"></param>
        /// <param name="paramValues"></param>
        /// <returns></returns>
        public virtual IEnumerable <T> ExecuteDeferred <T>(QueryCommand <T> query, object[] paramValues)
        {
            DbCommand cmd = this.GetCommand(query.CommandText, query.ParameterNames, paramValues);

            this.LogCommand(cmd);
            DbDataReader reader = cmd.ExecuteReader();
            List <T>     data   = new List <T>();

            while (reader.Read())
            {
                data.Add(query.Projector(reader));
            }
            reader.Close();

            foreach (var result in data)
            {
                yield return(result);
            }
        }