using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace parkMonitor.Database2
{
    /// <summary>
    /// 创建sqlCommand执行方法简单工厂
    /// </summary>
    class SimpleCommandFactory
    {
        /// <summary>
        /// 根据类型创建相应Command执行方法
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static AbstractCommand CreateCommandAndExcute(CommandTypes type)
        {
            AbstractCommand absCommands = null;

            switch (type)
            {
                case CommandTypes.NOQUERYCOMMAND:
                    absCommands = new NoQueryCommand();
                    break;
                case CommandTypes.QUERYCOMMAND:
                    absCommands = new QueryCommand();
                    break;
                case CommandTypes.SCALARCOMMAND:
                    absCommands = new ScalarCommand();
                    break;
                case CommandTypes.TRANSACTIONCOMMAND:
                    absCommands = new TransactionCommand();
                    break;
                case CommandTypes.STOREPROCEDURECOMMAND:
                    absCommands = new StoreProcedureCommand();
                    break;
                default:
                    break;
            }
            return absCommands;
        }
    }
}
