Esempio n. 1
0
        /// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(IntegralProductEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update IntegralProduct SET " +
                            "Title = @Title," +
                            "Price = @Price," +
                            "NeedIntegral = @NeedIntegral," +
                            "Picture = @Picture," +
                            "TypeID = @TypeID," +
                            "Stocks = @Stocks," +
                            "UpdateTime = @UpdateTime," +
                            "PictureBig = @PictureBig," +
                            "Content = @Content," +
                            "Description = @Description," +
                            "Keyword = @Keyword," +
                            "ExchangeTimes = @ExchangeTimes," +
                            "EliteLevel = @EliteLevel" +
                            " WHERE " +

                            "ID = @ID";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取实体(异步方式)
        /// </summary>
        /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
        /// <param name="dict">参数的名/值集合</param>
        /// <returns></returns>
        public virtual async Task <IntegralProductEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null)
        {
            IntegralProductEntity obj = null;
            string strSQL             = "select top 1 * from IntegralProduct where 1=1 " + strWhere;

            using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
            {
                if (reader.Read())
                {
                    obj = GetEntityFromrdr(reader);
                }
            }
            return(obj);
        }
Esempio n. 3
0
 /// <summary>
 /// 把实体类转换成键/值对集合
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="dict"></param>
 private static void GetParameters(IntegralProductEntity entity, Dictionary <string, object> dict)
 {
     dict.Add("ID", entity.ID);
     dict.Add("Title", entity.Title);
     dict.Add("Price", entity.Price);
     dict.Add("NeedIntegral", entity.NeedIntegral);
     dict.Add("Picture", entity.Picture);
     dict.Add("TypeID", entity.TypeID);
     dict.Add("Stocks", entity.Stocks);
     dict.Add("UpdateTime", entity.UpdateTime);
     dict.Add("PictureBig", entity.PictureBig);
     dict.Add("Content", entity.Content);
     dict.Add("Description", entity.Description);
     dict.Add("Keyword", entity.Keyword);
     dict.Add("ExchangeTimes", entity.ExchangeTimes);
     dict.Add("EliteLevel", entity.EliteLevel);
 }
Esempio n. 4
0
        /// <summary>
        /// 通过数据读取器生成实体类
        /// </summary>
        /// <param name="rdr"></param>
        /// <returns></returns>
        private static IntegralProductEntity GetEntityFromrdr(NullableDataReader rdr)
        {
            IntegralProductEntity info = new IntegralProductEntity();

            info.ID            = rdr.GetInt32("ID");
            info.Title         = rdr.GetString("Title");
            info.Price         = rdr.GetDecimal("Price");
            info.NeedIntegral  = rdr.GetInt32("NeedIntegral");
            info.Picture       = rdr.GetString("Picture");
            info.TypeID        = rdr.GetInt32("TypeID");
            info.Stocks        = rdr.GetInt32("Stocks");
            info.UpdateTime    = rdr.GetNullableDateTime("UpdateTime");
            info.PictureBig    = rdr.GetString("PictureBig");
            info.Content       = rdr.GetString("Content");
            info.Description   = rdr.GetString("Description");
            info.Keyword       = rdr.GetString("Keyword");
            info.ExchangeTimes = rdr.GetInt32("ExchangeTimes");
            info.EliteLevel    = rdr.GetInt32("EliteLevel");
            return(info);
        }
Esempio n. 5
0
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <int> InsertAsync(IntegralProductEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into IntegralProduct (" +
                            "Title," +
                            "Price," +
                            "NeedIntegral," +
                            "Picture," +
                            "TypeID," +
                            "Stocks," +
                            "UpdateTime," +
                            "PictureBig," +
                            "Content," +
                            "Description," +
                            "Keyword," +
                            "ExchangeTimes," +
                            "EliteLevel) " +
                            "values(" +
                            "@Title," +
                            "@Price," +
                            "@NeedIntegral," +
                            "@Picture," +
                            "@TypeID," +
                            "@Stocks," +
                            "@UpdateTime," +
                            "@PictureBig," +
                            "@Content," +
                            "@Description," +
                            "@Keyword," +
                            "@ExchangeTimes," +
                            "@EliteLevel)";

            return(await Task.Run(() => _DB.ReturnID(strSQL, dict)));
        }
Esempio n. 6
0
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual bool Add(IntegralProductEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into IntegralProduct (" +
                            "Title," +
                            "Price," +
                            "NeedIntegral," +
                            "Picture," +
                            "TypeID," +
                            "Stocks," +
                            "UpdateTime," +
                            "PictureBig," +
                            "Content," +
                            "Description," +
                            "Keyword," +
                            "ExchangeTimes," +
                            "EliteLevel) " +
                            "values(" +
                            "@Title," +
                            "@Price," +
                            "@NeedIntegral," +
                            "@Picture," +
                            "@TypeID," +
                            "@Stocks," +
                            "@UpdateTime," +
                            "@PictureBig," +
                            "@Content," +
                            "@Description," +
                            "@Keyword," +
                            "@ExchangeTimes," +
                            "@EliteLevel)";

            return(_DB.ExeSQLResult(strSQL, dict));
        }
Esempio n. 7
0
 /// <summary>
 /// 增加或更新一条记录(异步方式)
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual async Task <bool> AddOrUpdateAsync(IntegralProductEntity entity, bool IsSave)
 {
     return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity));
 }
Esempio n. 8
0
 /// <summary>
 /// 增加或更新一条记录
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual bool AddOrUpdate(IntegralProductEntity entity, bool IsSave)
 {
     return(IsSave ? Add(entity) : Update(entity));
 }