Example #1
0
        /// <summary>
        /// Execute the query and return a list or array of new instances of typed results filled with data table results.
        /// </summary>
        /// <typeparam name="T">Object type for first table</typeparam>
        /// <typeparam name="U">Object type for second table</typeparam>
        /// <returns>List of array of typed results</returns>
        /// <example>
        /// <code>
        ///   var data = cmd.ExecuteDataSet&lt;Employee, Department&gt;();
        ///   var employees = data.Item1;
        ///   var departments = data.Item2;
        /// </code>
        /// </example>
        public async virtual Task <Tuple <IEnumerable <T>, IEnumerable <U> > > ExecuteDataSetAsync <T, U>(T typeOfItem1, U typeOfItem2)
        {
            var datasets = await ExecuteInternalCommand(async() =>
            {
                using (DbDataReader dr = await this.Command.ExecuteReaderAsync())
                {
                    return(await DataReaderConvertor.ToMultipleTypesAsync <T, U, NoType, NoType, NoType>(dr, forAnonymousTypes: true));
                }
            });

            return(new Tuple <IEnumerable <T>, IEnumerable <U> >
                   (
                       datasets.Item1,
                       datasets.Item2
                   ));
        }
Example #2
0
        /// <summary>
        /// Execute the query and return a list or array of new instances of typed results filled with data table results.
        /// </summary>
        /// <typeparam name="T">Object type for first table</typeparam>
        /// <typeparam name="U">Object type for second table</typeparam>
        /// <typeparam name="V">Object type for third table</typeparam>
        /// <returns>List of array of typed results</returns>
        /// <example>
        /// <code>
        ///   var data = cmd.ExecuteDataSet&lt;Employee, Department&gt;();
        ///   var employees = data.Item1;
        ///   var departments = data.Item2;
        /// </code>
        /// </example>
        public async virtual Task <Tuple <IEnumerable <T>, IEnumerable <U>, IEnumerable <V> > > ExecuteDataSetAsync <T, U, V>()
        {
            var datasets = await ExecuteInternalCommand(async() =>
            {
                using (DbDataReader dr = await this.Command.ExecuteReaderAsync())
                {
                    return(await DataReaderConvertor.ToMultipleTypesAsync <T, U, V, NoType, NoType>(dr));
                }
            });

            return(new Tuple <IEnumerable <T>, IEnumerable <U>, IEnumerable <V> >
                   (
                       datasets.Item1,
                       datasets.Item2,
                       datasets.Item3
                   ));
        }