Example #1
0
        public void Insert(SpecialInfo specialInfo)
        {
            var sqlString = $@"INSERT INTO {TableName}
           ({nameof(SpecialInfo.SiteId)}, 
            {nameof(SpecialInfo.Title)}, 
            {nameof(SpecialInfo.Url)},
            {nameof(SpecialInfo.AddDate)})
     VALUES
           (@{nameof(SpecialInfo.SiteId)}, 
            @{nameof(SpecialInfo.Title)}, 
            @{nameof(SpecialInfo.Url)}, 
            @{nameof(SpecialInfo.AddDate)})";

            IDataParameter[] parameters =
            {
                GetParameter(nameof(specialInfo.SiteId),  DataType.Integer,  specialInfo.SiteId),
                GetParameter(nameof(specialInfo.Title),   DataType.VarChar,                  200,specialInfo.Title),
                GetParameter(nameof(specialInfo.Url),     DataType.VarChar,                  200,specialInfo.Url),
                GetParameter(nameof(specialInfo.AddDate), DataType.DateTime, specialInfo.AddDate)
            };

            ExecuteNonQuery(sqlString, parameters);

            SpecialManager.RemoveCache(specialInfo.SiteId);
        }
Example #2
0
        public void Delete(int siteId, int specialId)
        {
            if (specialId <= 0) return;

            var sqlString = $"DELETE FROM {TableName} WHERE {nameof(SpecialInfo.Id)} = {specialId}";
            ExecuteNonQuery(sqlString);

            SpecialManager.RemoveCache(siteId);
        }
Example #3
0
        public void Update(SpecialInfo specialInfo)
        {
            var sqlString = $@"UPDATE {TableName} SET
                {nameof(SpecialInfo.SiteId)} = @{nameof(SpecialInfo.SiteId)},  
                {nameof(SpecialInfo.Title)} = @{nameof(SpecialInfo.Title)}, 
                {nameof(SpecialInfo.Url)} = @{nameof(SpecialInfo.Url)},
                {nameof(SpecialInfo.AddDate)} = @{nameof(SpecialInfo.AddDate)}
            WHERE {nameof(SpecialInfo.Id)} = @{nameof(SpecialInfo.Id)}";

            IDataParameter[] parameters =
            {
                GetParameter(nameof(specialInfo.SiteId),  DataType.Integer,  specialInfo.SiteId),
                GetParameter(nameof(specialInfo.Title),   DataType.VarChar,                   200,specialInfo.Title),
                GetParameter(nameof(specialInfo.Url),     DataType.VarChar,                   200,specialInfo.Url),
                GetParameter(nameof(specialInfo.AddDate), DataType.DateTime, specialInfo.AddDate),
                GetParameter(nameof(specialInfo.Id),      DataType.Integer,  specialInfo.Id)
            };

            ExecuteNonQuery(sqlString, parameters);

            SpecialManager.RemoveCache(specialInfo.SiteId);
        }