Ejemplo n.º 1
0
        public string SqlString()
        {
            string    sql    = string.Empty;
            SqlEntity entity = GetSqlEntity();

            switch (this._type)
            {
            case SqlType.Query:
                sql = _adapter.Query(entity);
                break;

            case SqlType.Insert:
                sql = _adapter.Insert(_userKey, entity);
                break;

            case SqlType.Update:
                sql = _adapter.Update(entity);
                break;

            case SqlType.Delete:
                sql = _adapter.Delete(entity);
                break;

            default:
                break;
            }
            return(sql);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Queries the specified connection.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="connection">The connection.</param>
        /// <param name="sql">The SQL.</param>
        /// <param name="param">The parameter.</param>
        /// <param name="transaction">The transaction.</param>
        /// <param name="buffered">if set to <c>true</c> [buffered].</param>
        /// <param name="commandTimeout">The command timeout.</param>
        /// <param name="commandType">Type of the command.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">connection;connection cannot be null</exception>
        /// <exception cref="System.ApplicationException">ConnectionState must be Open, current state:  + connection.State</exception>
        public static IEnumerable <T> Query <T>(this IDbConnection connection, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null)
        {
            // Argument Validation
            if (connection == null)
            {
                throw new ArgumentNullException("connection", "connection cannot be null");
            }

            InitializeCacheSweeper();

            // Execute
            ISqlAdapter adapter = GetFormatter(connection);
            var         results = adapter.Query <T>(connection, sql, param, transaction, buffered, commandTimeout, commandType);

            return(results);
        }
Ejemplo n.º 3
0
 public void Run(ISqlAdapter sqlAdapter)
 {
     var a  = sqlAdapter.Query <UserCenter.DataModel.DB_User>();
     var aa = a.ToList();
 }