using ProjectBase.Data.BaseDAL.BaseDatabase;
using ProjectBase.Util;
using SIASUN.Autopilot.DAL.IDALSQL;
using SIASUN.Autopilot.Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SIASUN.Autopilot.DAL.DALSQL
{
    public class DalAuthoryRight : BaseDALSQL<MoAuthoryRight>, IDalAuthoryRight
    {
        #region 对象实例及构造函数

        public static DalAuthoryRight Instance
        {
            get
            {
                return new DalAuthoryRight();
            }
        } 
        public DalAuthoryRight() : base("authory_right", new string[] { "right_id" })
        {
            this.sortField = "right_id";
            this.isDescending = false;
        }

        #endregion

        /// <summary>
        /// 将DataReader的属性值转化为实体类的属性值，返回实体类
        /// </summary>
        /// <param name="dr">有效的DataReader对象</param>
        /// <returns>实体类对象</returns>
        protected override MoAuthoryRight DataReaderToEntity(IDataReader dataReader)
        {
            MoAuthoryRight info = new MoAuthoryRight();
            SmartDataReader reader = new SmartDataReader(dataReader);

            info.RightId = reader.GetString("right_id");
            info.ParentRightId = reader.GetString("parent_right_id");
            info.RightName = reader.GetString("right_name");
            info.RightDescription = reader.GetString("right_description");
            return info;
        }


        /// <summary>
        /// 将实体对象的属性值转化为Hashtable对应的键值
        /// </summary>
        /// <param name="obj">有效的实体对象</param> 
        /// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(MoAuthoryRight obj)
        {
            MoAuthoryRight info = obj as MoAuthoryRight;
            Hashtable hash = new Hashtable();

            hash.Add("right_id", info.RightId);
            hash.Add("parent_right_id", info.ParentRightId);
            hash.Add("right_name", info.RightName);
            hash.Add("right_description", info.RightDescription);

            return hash;
        }

    }
}
