コード例 #1
0
ファイル: DatabaseCommand.cs プロジェクト: jmbechet/Dev.Data
        /// <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 virtual Tuple <IEnumerable <T>, IEnumerable <U> > ExecuteDataSet <T, U>(T typeOfItem1, U typeOfItem2)
        {
            var datasets = ExecuteInternalCommand(() =>
            {
                using (DbDataReader dr = this.Command.ExecuteReader())
                {
                    return(DataReaderConvertor.ToMultipleTypes <T, U, NoType, NoType, NoType>(dr, forAnonymousTypes: true));
                }
            });

            return(new Tuple <IEnumerable <T>, IEnumerable <U> >
                   (
                       datasets.Item1,
                       datasets.Item2
                   ));
        }
コード例 #2
0
ファイル: DatabaseCommand.cs プロジェクト: jmbechet/Dev.Data
        /// <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 virtual Tuple <IEnumerable <T>, IEnumerable <U>, IEnumerable <V> > ExecuteDataSet <T, U, V>()
        {
            var datasets = ExecuteInternalCommand(() =>
            {
                using (DbDataReader dr = this.Command.ExecuteReader())
                {
                    return(DataReaderConvertor.ToMultipleTypes <T, U, V, NoType, NoType>(dr));
                }
            });

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