/// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Member.FavoriteModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Member.FavoriteModel model = new NoName.NetShop.Member.FavoriteModel();
            object ojb;

            model.UserId = dataReader["UserId"].ToString();
            ojb          = dataReader["FavoriteId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FavoriteId = (int)ojb;
            }
            model.FavoriteUrl  = dataReader["FavoriteUrl"].ToString();
            model.FavoriteName = dataReader["FavoriteName"].ToString();
            ojb = dataReader["InsertTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InsertTime = (DateTime)ojb;
            }
            ojb = dataReader["ContentId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContentId = (int)ojb;
            }
            ojb = dataReader["ContentType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContentType = (ContentType)Convert.ToInt32(ojb);
            }
            return(model);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Member.FavoriteModel GetModel(int FavoriteId)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_umFavorite_GetModel");

            db.AddInParameter(dbCommand, "FavoriteId", DbType.Int32, FavoriteId);

            NoName.NetShop.Member.FavoriteModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public void Add(NoName.NetShop.Member.FavoriteModel model)
        {
            Database db = CommDataAccess.DbWriter;

            if (!this.Exists(model.UserId, model.ContentId, model.ContentType))
            {
                model.FavoriteId = CommDataHelper.GetNewSerialNum(AppType.Other);
                DbCommand dbCommand = db.GetStoredProcCommand("UP_umFavorite_ADD");
                db.AddInParameter(dbCommand, "UserId", DbType.AnsiString, model.UserId);
                db.AddInParameter(dbCommand, "FavoriteId", DbType.Int32, model.FavoriteId);
                db.AddInParameter(dbCommand, "FavoriteUrl", DbType.AnsiString, model.FavoriteUrl);
                db.AddInParameter(dbCommand, "FavoriteName", DbType.AnsiString, model.FavoriteName);
                db.AddInParameter(dbCommand, "ContentId", DbType.Int32, model.ContentId);
                db.AddInParameter(dbCommand, "ContentType", DbType.Byte, model.ContentType);
                db.ExecuteNonQuery(dbCommand);
            }
        }
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public NoName.NetShop.Member.FavoriteModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Member.FavoriteModel model = new NoName.NetShop.Member.FavoriteModel();
     object ojb;
     model.UserId = dataReader["UserId"].ToString();
     ojb = dataReader["FavoriteId"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.FavoriteId = (int)ojb;
     }
     model.FavoriteUrl = dataReader["FavoriteUrl"].ToString();
     model.FavoriteName = dataReader["FavoriteName"].ToString();
     ojb = dataReader["InsertTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.InsertTime = (DateTime)ojb;
     }
     ojb = dataReader["ContentId"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.ContentId = (int)ojb;
     }
     ojb = dataReader["ContentType"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.ContentType = (ContentType)Convert.ToInt32(ojb);
     }
     return model;
 }
Example #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(NoName.NetShop.Member.FavoriteModel model)
 {
     dal.Add(model);
 }