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

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

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

        #endregion

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

            info.GroupId = reader.GetString("group_id");
            info.GroupName = reader.GetString("group_name");
            info.ParentGroupId = reader.GetString("parent_group_id");
            info.GroupTime = reader.GetString("group_time");
            return info;
        }

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

            hash.Add("group_id", info.GroupId);
            hash.Add("group_name", info.GroupName);
            hash.Add("parent_group_id", info.ParentGroupId);
            hash.Add("group_time", info.GroupTime);

            return hash;
        }
    }
}
