Esempio n. 1
0
        /// <summary>
        /// Executes a Query SQL Statement in an Embedded Resource.  An exception will be thrown if the connection is not open.
        /// </summary>
        /// <param name="connection">IDbConnection</param>
        /// <param name="embeddedResource">Embedded Resource Name</param>
        /// <param name="assembly">Assembly Where Embedded Resource Resides</param>
        /// <param name="commandCallback">Parameter lambda expression callback in the form (command) => { }</param>
        /// <param name="readerCallback">Reader lambda expression callback in the form (reader) => { }</param>
        /// <param name="validateParameters">If set to <c>true</c> validate parameters.</param>
        public static void ExecuteQueryEmbeddedResource(this IDbConnection connection, string embeddedResource, System.Reflection.Assembly assembly, Action <IDbCommand> commandCallback, Action <IDataReader> readerCallback, bool validateParameters = false)
        {
            if (embeddedResource == null)
            {
                throw new ArgumentNullException(nameof(embeddedResource));
            }

            string sql = assembly.GetEmbeddedResourceString(embeddedResource);

            connection.ExecuteQueryString(sql, commandCallback, readerCallback, validateParameters);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new IDbCommand with an initialized from a specifed embedded resource.
        /// </summary>
        /// <returns>The with embedded resource.</returns>
        /// <param name="connection">IDbConnection</param>
        /// <param name="embeddedResource">Embedded resource name</param>
        /// <param name="assembly">Assembly where embedded resource exists</param>
        public static IDbCommand CommandWithEmbeddedResource(this IDbConnection connection, string embeddedResource, System.Reflection.Assembly assembly)
        {
            if (embeddedResource == null)
            {
                throw new ArgumentNullException(nameof(embeddedResource));
            }
            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            string sql = assembly.GetEmbeddedResourceString(embeddedResource);

            return(connection.CommandWithSqlString(sql));
        }
Esempio n. 3
0
        /// <summary>
        /// Executes a Query SQL statement, returning a scalar value. An exception will be thrown if the connection is not open.
        /// </summary>
        /// <param name="connection">IDbConnection</param>
        /// <param name="embeddedResource">Embedded Resource Name</param>
        /// <param name="assembly">Assembly Where Embedded Resource Resides</param>
        /// <param name="commandCallback">Parameter lambda expression callback in the form (command) => { }</param>
        /// <param name="validateParameters">If set to <c>true</c> validate parameters.</param>
        /// <returns>Scalar value</returns>
        public static object ExecuteScalarEmbeddedResource(this IDbConnection connection, string embeddedResource, System.Reflection.Assembly assembly, Action <IDbCommand> commandCallback = null, bool validateParameters = false)
        {
            if (embeddedResource == null)
            {
                throw new ArgumentNullException(nameof(embeddedResource));
            }
            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            string sql = assembly.GetEmbeddedResourceString(embeddedResource);

            return(connection.ExecuteQueryScalar(sql, commandCallback, validateParameters));
        }
Esempio n. 4
0
        /// <summary>
        /// Executes a Non Query SQL Statement from an embedded resource for a DbField decorated object.  Sql Parameters will be automatically populated.
        /// An exception will be thrown if the connection is not open.
        /// </summary>
        /// <param name="connection">IDbConnection</param>
        /// <param name="embeddedResource">Embedded Resource Name</param>
        /// <param name="assembly">Assembly Where Embedded Resource Resides</param>
        /// <param name="obj">Model object from which parameters are to be populated</param>
        /// <param name="validateParameters">If set to <c>true</c> validate parameters.</param>
        /// <returns>Number of records affected</returns>
        /// <typeparam name="T">Data Type</typeparam>
        public static int ExecuteNonQueryEmbeddedResourceForObject <T>(this IDbConnection connection, string embeddedResource, System.Reflection.Assembly assembly, T obj, bool validateParameters = false) where T : class
        {
            if (embeddedResource == null)
            {
                throw new ArgumentNullException(nameof(embeddedResource));
            }
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }
            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            string sql = assembly.GetEmbeddedResourceString(embeddedResource);

            return(connection.ExecuteNonQueryStringForObject(sql, obj, validateParameters));
        }
Esempio n. 5
0
        /// <summary>
        /// Executes a Query SQL Statement in an Embedded Resource.  An exception will be thrown if the connection is not open.
        /// </summary>
        /// <param name="connection">IDbConnection</param>
        /// <param name="embeddedResource">Embedded Resource Name</param>
        /// <param name="assembly">Assembly Where Embedded Resource Resides</param>
        /// <param name="readerCallback">Reader lambda expression callback in the form (reader) => { }</param>
        /// <param name="validateParameters">If set to <c>true</c> validate parameters.</param>
        public static void ExecuteQueryEmbeddedResource(this IDbConnection connection, string embeddedResource, System.Reflection.Assembly assembly, Action <IDataReader> readerCallback, bool validateParameters = false)
        {
            string sql = assembly.GetEmbeddedResourceString(embeddedResource);

            connection.ExecuteQueryString(sql, null, readerCallback, validateParameters);
        }