/// <summary>
 /// 把实体类转换成键/值对集合
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="dict"></param>
 private static void GetParameters(StatMonthEntity entity, Dictionary <string, object> dict)
 {
     dict.Add("D1", entity.D1);
     dict.Add("D2", entity.D2);
     dict.Add("D3", entity.D3);
     dict.Add("D4", entity.D4);
     dict.Add("D5", entity.D5);
     dict.Add("D6", entity.D6);
     dict.Add("D7", entity.D7);
     dict.Add("D8", entity.D8);
     dict.Add("D9", entity.D9);
     dict.Add("D10", entity.D10);
     dict.Add("D11", entity.D11);
     dict.Add("D12", entity.D12);
     dict.Add("D13", entity.D13);
     dict.Add("D14", entity.D14);
     dict.Add("D15", entity.D15);
     dict.Add("D16", entity.D16);
     dict.Add("D17", entity.D17);
     dict.Add("D18", entity.D18);
     dict.Add("D19", entity.D19);
     dict.Add("D20", entity.D20);
     dict.Add("D21", entity.D21);
     dict.Add("D22", entity.D22);
     dict.Add("D23", entity.D23);
     dict.Add("D24", entity.D24);
     dict.Add("D25", entity.D25);
     dict.Add("D26", entity.D26);
     dict.Add("D27", entity.D27);
     dict.Add("D28", entity.D28);
     dict.Add("D29", entity.D29);
     dict.Add("D30", entity.D30);
     dict.Add("D31", entity.D31);
     dict.Add("TMonth", entity.TMonth);
 }
        /// <summary>
        /// 获取实体(异步方式)
        /// </summary>
        /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
        /// <param name="dict">参数的名/值集合</param>
        /// <returns></returns>
        public virtual async Task <StatMonthEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null)
        {
            StatMonthEntity obj    = null;
            string          strSQL = "select top 1 * from StatMonth where 1=1 " + strWhere;

            using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
            {
                if (reader.Read())
                {
                    obj = GetEntityFromrdr(reader);
                }
            }
            return(obj);
        }
        /// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(StatMonthEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update StatMonth SET " +
                            "D1 = @D1," +
                            "D2 = @D2," +
                            "D3 = @D3," +
                            "D4 = @D4," +
                            "D5 = @D5," +
                            "D6 = @D6," +
                            "D7 = @D7," +
                            "D8 = @D8," +
                            "D9 = @D9," +
                            "D10 = @D10," +
                            "D11 = @D11," +
                            "D12 = @D12," +
                            "D13 = @D13," +
                            "D14 = @D14," +
                            "D15 = @D15," +
                            "D16 = @D16," +
                            "D17 = @D17," +
                            "D18 = @D18," +
                            "D19 = @D19," +
                            "D20 = @D20," +
                            "D21 = @D21," +
                            "D22 = @D22," +
                            "D23 = @D23," +
                            "D24 = @D24," +
                            "D25 = @D25," +
                            "D26 = @D26," +
                            "D27 = @D27," +
                            "D28 = @D28," +
                            "D29 = @D29," +
                            "D30 = @D30," +
                            "D31 = @D31" +
                            " WHERE " +

                            "TMonth = @TMonth";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
        /// <summary>
        /// 通过数据读取器生成实体类
        /// </summary>
        /// <param name="rdr"></param>
        /// <returns></returns>
        private static StatMonthEntity GetEntityFromrdr(NullableDataReader rdr)
        {
            StatMonthEntity info = new StatMonthEntity();

            info.D1     = rdr.GetInt32("D1");
            info.D2     = rdr.GetInt32("D2");
            info.D3     = rdr.GetInt32("D3");
            info.D4     = rdr.GetInt32("D4");
            info.D5     = rdr.GetInt32("D5");
            info.D6     = rdr.GetInt32("D6");
            info.D7     = rdr.GetInt32("D7");
            info.D8     = rdr.GetInt32("D8");
            info.D9     = rdr.GetInt32("D9");
            info.D10    = rdr.GetInt32("D10");
            info.D11    = rdr.GetInt32("D11");
            info.D12    = rdr.GetInt32("D12");
            info.D13    = rdr.GetInt32("D13");
            info.D14    = rdr.GetInt32("D14");
            info.D15    = rdr.GetInt32("D15");
            info.D16    = rdr.GetInt32("D16");
            info.D17    = rdr.GetInt32("D17");
            info.D18    = rdr.GetInt32("D18");
            info.D19    = rdr.GetInt32("D19");
            info.D20    = rdr.GetInt32("D20");
            info.D21    = rdr.GetInt32("D21");
            info.D22    = rdr.GetInt32("D22");
            info.D23    = rdr.GetInt32("D23");
            info.D24    = rdr.GetInt32("D24");
            info.D25    = rdr.GetInt32("D25");
            info.D26    = rdr.GetInt32("D26");
            info.D27    = rdr.GetInt32("D27");
            info.D28    = rdr.GetInt32("D28");
            info.D29    = rdr.GetInt32("D29");
            info.D30    = rdr.GetInt32("D30");
            info.D31    = rdr.GetInt32("D31");
            info.TMonth = rdr.GetString("TMonth");
            return(info);
        }
 /// <summary>
 /// 增加或更新一条记录(异步方式)
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual async Task <bool> AddOrUpdateAsync(StatMonthEntity entity, bool IsSave)
 {
     return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity));
 }
 /// <summary>
 /// 增加或更新一条记录
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual bool AddOrUpdate(StatMonthEntity entity, bool IsSave)
 {
     return(IsSave ? Add(entity) : Update(entity));
 }
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <int> InsertAsync(StatMonthEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into StatMonth (" +
                            "D1," +
                            "D2," +
                            "D3," +
                            "D4," +
                            "D5," +
                            "D6," +
                            "D7," +
                            "D8," +
                            "D9," +
                            "D10," +
                            "D11," +
                            "D12," +
                            "D13," +
                            "D14," +
                            "D15," +
                            "D16," +
                            "D17," +
                            "D18," +
                            "D19," +
                            "D20," +
                            "D21," +
                            "D22," +
                            "D23," +
                            "D24," +
                            "D25," +
                            "D26," +
                            "D27," +
                            "D28," +
                            "D29," +
                            "D30," +
                            "D31," +
                            "TMonth) " +
                            "values(" +
                            "@D1," +
                            "@D2," +
                            "@D3," +
                            "@D4," +
                            "@D5," +
                            "@D6," +
                            "@D7," +
                            "@D8," +
                            "@D9," +
                            "@D10," +
                            "@D11," +
                            "@D12," +
                            "@D13," +
                            "@D14," +
                            "@D15," +
                            "@D16," +
                            "@D17," +
                            "@D18," +
                            "@D19," +
                            "@D20," +
                            "@D21," +
                            "@D22," +
                            "@D23," +
                            "@D24," +
                            "@D25," +
                            "@D26," +
                            "@D27," +
                            "@D28," +
                            "@D29," +
                            "@D30," +
                            "@D31," +
                            "@TMonth)";

            if (await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)))
            {
                return(DataConverter.CLng(entity.TMonth));
            }
            return(-1);
        }
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual bool Add(StatMonthEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into StatMonth (" +
                            "D1," +
                            "D2," +
                            "D3," +
                            "D4," +
                            "D5," +
                            "D6," +
                            "D7," +
                            "D8," +
                            "D9," +
                            "D10," +
                            "D11," +
                            "D12," +
                            "D13," +
                            "D14," +
                            "D15," +
                            "D16," +
                            "D17," +
                            "D18," +
                            "D19," +
                            "D20," +
                            "D21," +
                            "D22," +
                            "D23," +
                            "D24," +
                            "D25," +
                            "D26," +
                            "D27," +
                            "D28," +
                            "D29," +
                            "D30," +
                            "D31," +
                            "TMonth) " +
                            "values(" +
                            "@D1," +
                            "@D2," +
                            "@D3," +
                            "@D4," +
                            "@D5," +
                            "@D6," +
                            "@D7," +
                            "@D8," +
                            "@D9," +
                            "@D10," +
                            "@D11," +
                            "@D12," +
                            "@D13," +
                            "@D14," +
                            "@D15," +
                            "@D16," +
                            "@D17," +
                            "@D18," +
                            "@D19," +
                            "@D20," +
                            "@D21," +
                            "@D22," +
                            "@D23," +
                            "@D24," +
                            "@D25," +
                            "@D26," +
                            "@D27," +
                            "@D28," +
                            "@D29," +
                            "@D30," +
                            "@D31," +
                            "@TMonth)";

            return(_DB.ExeSQLResult(strSQL, dict));
        }