public bool Update(ShareArticleEntity model) { var description = "更新分享文章"; try { var sql = @"update [dbo].[ShareArticle] set [Title]=@Title, [ArticleUrl]=@ArticleUrl, [ArticleType]=@ArticleType, [CreatedTime]=@CreatedTime, [UpdatedTime]=@UpdatedTime, [Cover]=@Cover Where Id=@Id "; var sqlParameter = new List <SqlParameter> { new SqlParameter("@Id", SqlDbType.BigInt) { Value = model.Id }, new SqlParameter("@Title", SqlDbType.NVarChar) { Value = model.Title }, new SqlParameter("@ArticleUrl", SqlDbType.NVarChar) { Value = model.ArticleUrl }, new SqlParameter("@ArticleType", SqlDbType.Int) { Value = model.ArticleType }, new SqlParameter("@CreatedTime", SqlDbType.DateTime) { Value = model.CreatedTime }, new SqlParameter("@UpdatedTime", SqlDbType.DateTime) { Value = model.UpdatedTime }, new SqlParameter("@Cover", SqlDbType.NVarChar) { Value = model.Cover }, }; RPoney.Log.LoggerManager.Debug(GetType().Name, $"{description}sql:{sql},参数:model{model.SerializeToJSON()}"); return(DataBaseManager.MainDb().ExecuteNonQuery(sql, sqlParameter.ToArray()) > 0); } catch (Exception ex) { RPoney.Log.LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(false); } }
public long Add(ShareArticleEntity model) { var description = "添加分享文章"; try { var sql = @"INSERT INTO [dbo].[ShareArticle]([Title],[ArticleUrl],[ArticleType],[CreatedTime],[UpdatedTime],[Cover]) Values(@Title,@ArticleUrl,@ArticleType,@CreatedTime,@UpdatedTime,@Cover);select @@Identity;"; var sqlParameter = new List <SqlParameter> { new SqlParameter("@Title", SqlDbType.NVarChar) { Value = model.Title }, new SqlParameter("@ArticleUrl", SqlDbType.NVarChar) { Value = model.ArticleUrl }, new SqlParameter("@ArticleType", SqlDbType.Int) { Value = model.ArticleType }, new SqlParameter("@CreatedTime", SqlDbType.DateTime) { Value = model.CreatedTime }, new SqlParameter("@UpdatedTime", SqlDbType.DateTime) { Value = model.UpdatedTime }, new SqlParameter("@Cover", SqlDbType.NVarChar) { Value = model.Cover }, }; RPoney.Log.LoggerManager.Debug(GetType().Name, $"{description}sql:{sql},参数:model{model.SerializeToJSON()}"); return(DataBaseManager.MainDb().ExecuteScalar(sql, sqlParameter.ToArray()).CLong(0, false)); } catch (Exception ex) { RPoney.Log.LoggerManager.Error(GetType().Name, $"{description}异常", ex); return(-1); } }