/// <summary>
            /// Returns the first record from the query result.
            /// </summary>
            /// <returns>depending on T, single value or all fields values from the first record</returns>
            public T Single <T>()
            {
                var res = new SingleDataReaderResult <T>(Read <T>);

                using (var selectCmd = GetSelectCmd()) {
                    DataHelper.ExecuteReader(selectCmd, CommandBehavior.SingleRow, DataReaderRecordOffset, 1, res);
                }
                return(res.Result);
            }
            /// <summary>
            /// Returns dictionary with first record values.
            /// </summary>
            /// <returns>dictionary with field values or null if query returns zero records.</returns>
            public Dictionary <string, object> ToDictionary()
            {
                var res = new SingleDataReaderResult <Dictionary <string, object> >(ReadDictionary);

                using (var selectCmd = GetSelectCmd()) {
                    DataHelper.ExecuteReader(selectCmd, CommandBehavior.SingleRow, DataReaderRecordOffset, 1, res);
                }
                return(res.Result);
            }
            /// <summary>
            /// Returns all query results as <see cref="RecordSet"/>.
            /// </summary>
            public RecordSet ToRecordSet()
            {
                var res = new RecordSetDataReaderResult();

                using (var selectCmd = GetSelectCmd()) {
                    DataHelper.ExecuteReader(selectCmd, CommandBehavior.Default, DataReaderRecordOffset, RecordCount, res);
                }
                return(res.Result);
            }
            /// <summary>
            /// Returns a list with all query results.
            /// </summary>
            /// <returns>list with query results</returns>
            public List <T> ToList <T>()
            {
                var res = new ListDataReaderResult <T>(Read <T>);

                using (var selectCmd = GetSelectCmd()) {
                    DataHelper.ExecuteReader(selectCmd, CommandBehavior.Default, DataReaderRecordOffset, RecordCount, res);
                }
                return(res.Result);
            }
Beispiel #5
0
            /// <summary>
            /// Returns the first record from the query result.
            /// </summary>
            /// <returns>depending on T, single value or all fields values from the first record</returns>
            public T Single <T>()
            {
                T result = default(T);

                using (var selectCmd = GetSelectCmd()) {
                    DataHelper.ExecuteReader(selectCmd, CommandBehavior.SingleRow, DataReaderRecordOffset, 1,
                                             (rdr) => {
                        result = Read <T>(rdr);
                    });
                }
                return(result);
            }
Beispiel #6
0
            /// <summary>
            /// Returns a list with all query results.
            /// </summary>
            /// <returns>list with query results</returns>
            public List <T> ToList <T>()
            {
                var result = new List <T>();

                using (var selectCmd = GetSelectCmd()) {
                    DataHelper.ExecuteReader(selectCmd, CommandBehavior.Default, DataReaderRecordOffset, RecordCount,
                                             (rdr) => {
                        result.Add(Read <T>(rdr));
                    });
                }
                return(result);
            }
Beispiel #7
0
            /// <summary>
            /// Returns dictionary with first record values.
            /// </summary>
            /// <returns>dictionary with field values or null if query returns zero records.</returns>
            public Dictionary <string, object> ToDictionary()
            {
                Dictionary <string, object> result = null;

                using (var selectCmd = GetSelectCmd()) {
                    DataHelper.ExecuteReader(selectCmd, CommandBehavior.SingleRow, DataReaderRecordOffset, 1,
                                             (rdr) => {
                        result = ReadDictionary(rdr);
                    });
                }
                return(result);
            }