Esempio n. 1
0
        protected DbDataReader GetDataReader(DbConnection dbConnection, string sql)
        {
            DbCommander  dbCommander = new DbCommander(dbConnection, System.Data.CommandType.Text, sql);
            DbDataReader dataReader  = dbCommander.ExecteReader();

            return(dataReader);
        }
Esempio n. 2
0
        protected object GetScalar(DbConnection dbConnection, string sql)
        {
            DbCommander dbCommander = new DbCommander(dbConnection, System.Data.CommandType.Text, sql);
            object      obj         = dbCommander.ExecuteScalar();

            return(obj);
        }
Esempio n. 3
0
        public void ExecuteNonQuery(DbConnection dbConnection, string sql, Dictionary <string, object> paramaters = null, bool disposeConnection = true)
        {
#if disposeConnection
            using (dbConnection)
#endif
            {
                DbCommander dbCommander = new DbCommander(dbConnection, System.Data.CommandType.Text, sql);

                if (paramaters != null)
                {
                    var cmdParams = this.BuildCommandParameters(paramaters);
                    if (cmdParams != null)
                    {
                        dbCommander.DbCommand.Parameters.AddRange(cmdParams.ToArray());
                    }
                }

                dbCommander.ExecuteNonQuery();
            }
        }
Esempio n. 4
0
        public async Task <int> InteralExecuteNonQuery(DbConnection dbConnection, string sql, Dictionary <string, object> paramaters = null, bool disposeConnection = true, bool async = false)
        {
#if disposeConnection
            using (dbConnection)
#endif
            {
                DbCommander dbCommander = new DbCommander(dbConnection, System.Data.CommandType.Text, sql);

                if (paramaters != null)
                {
                    var cmdParams = this.BuildCommandParameters(paramaters);
                    if (cmdParams != null)
                    {
                        dbCommander.DbCommand.Parameters.AddRange(cmdParams.ToArray());
                    }
                }

                int result = async ? await dbCommander.ExecuteNonQueryAsync() : dbCommander.ExecuteNonQuery();

                return(result);
            }
        }