using MMoneyCoderSharp.DB;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MMoneyCoderSharp.Data;

namespace MMoneyCoderSharp.Data.Request
{
    /// <summary>
    /// Data Access Object 
    /// </summary>
    public abstract class ADataObject : IDataRequest
    {

        public ADataObject()
        {
            mRequestQuery = new Dictionary<string, string>();
            mReturnDataSet = new DataSet();
        }

        /// <summary>
        /// 완성되어 DB로 전송될 쿼리
        /// </summary>
        protected Dictionary<string, string> mRequestQuery = new Dictionary<string, string>();

        /// <summary>
        /// 완성되어 결과를 리턴할 데이터 셋
        /// </summary>
        protected DataSet mReturnDataSet = null;
       
        public string getQuery(string tableName)
        {
            return mRequestQuery[tableName];
        }

        public abstract IDataRequest buildData();

        public DataSet getResult()
        {
            foreach (KeyValuePair<string, string> item in mRequestQuery)
            {
                mReturnDataSet.Tables.Add(
                    DataQueryExecutor.Current.Execute(DataSourceKind.Oracle, item.Key, item.Value));
            }

            return mReturnDataSet;
        }
    }
}
