Exemplo n.º 1
0
        /// <summary>
        /// Retrieves list of UserMachineMap objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of UserMachineMap objects</returns>
        private UserMachineMapList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //UserMachineMap list
            UserMachineMapList list = new UserMachineMapList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    UserMachineMap userMachineMapObject = new UserMachineMap();
                    FillObject(userMachineMapObject, reader);

                    list.Add(userMachineMapObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves UserMachineMap object from SqlCommand, after database query
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <returns>UserMachineMap object</returns>
        private UserMachineMap GetObject(SqlCommand cmd)
        {
            SqlDataReader reader;
            long          rows = SelectRecords(cmd, out reader);

            using (reader)
            {
                if (reader.Read())
                {
                    UserMachineMap userMachineMapObject = new UserMachineMap();
                    FillObject(userMachineMapObject, reader);
                    return(userMachineMapObject);
                }
                else
                {
                    return(null);
                }
            }
        }