Exemple #1
0
        /// <summary>
        /// Executes a nonquery stored procedure and returns the number of rows affected in the database
        /// <para>
        /// Optional: Sets the custom configuration name <seealso cref="SQLAdapterConfiguration.SetConfig(string, string)"/>
        /// </para>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="clazz"></param>
        /// <param name="storedProcedureName"></param>
        /// <param name="adapterConfigurationFileName"></param>
        /// <returns></returns>
        public static int Push <T>(this T clazz, string storedProcedureName, string adapterConfigurationFileName = "SqlDataAdapter.config", string adapterConfigurationFilePath = "") where T : ColumnMap
        {
            SQLAdapterConfiguration.SetConfig(adapterConfigurationFileName, adapterConfigurationFilePath);
            Command cmd = new Command(storedProcedureName);

            return(DAO.ExecuteNonQuery(cmd.ToCommand(clazz)));
        }
Exemple #2
0
        /// <summary>
        /// Populates a single instance of class T using the first record of the results of the executed stored procedure
        /// <para>
        /// Optional: Sets the custom configuration name <seealso cref="SQLAdapterConfiguration.SetConfig(string, string)"/>
        /// </para>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="clazz"></param>
        /// <param name="storedProcedureName"></param>
        /// <param name="adapterConfigurationFileName"></param>
        /// <returns></returns>
        public static T Populate <T>(this T clazz, string storedProcedureName, string adapterConfigurationFileName = "SqlDataAdapter.config", string adapterConfigurationFilePath = "") where T : ColumnMap
        {
            SQLAdapterConfiguration.SetConfig(adapterConfigurationFileName, adapterConfigurationFilePath);
            Command cmd    = new Command(storedProcedureName);
            T       result = DAO.ExecuteQuery(cmd.ToCommand(clazz)).ToColumnMap(clazz);

            cmd.Dispose();
            return(result);
        }