コード例 #1
0
 /// <summary>
 /// 向数据库中添加一条记录
 /// </summary>
 /// <param name="model">要添加的实体</param>
 /// <returns>插入数据的ID</returns>
 public int Insert(PictureInfoModel model)
 {
     #region SQL语句
     const string sql = @"
     INSERT INTO [dbo].[PictureInfo] (
     [LargeImgPath]
     ,[UploadDate]
     ,[Width]
     ,[Height]
     ,[ImgSummary]
     ,[CollectCount]
     ,[UId]
     )
     VALUES (
     @LargeImgPath
     ,@UploadDate
     ,@Width
     ,@Height
     ,@ImgSummary
     ,@CollectCount
     ,@UId
     );select @@IDENTITY";
     #endregion
     var res = SqlHelper.ExecuteScalar(sql,
             new SqlParameter("@LargeImgPath", model.LargeImgPath),
             new SqlParameter("@UploadDate", model.UploadDate),
             new SqlParameter("@Width", model.Width),
             new SqlParameter("@Height", model.Height),
             new SqlParameter("@ImgSummary", model.ImgSummary),
             new SqlParameter("@CollectCount", model.CollectCount),
             new SqlParameter("@UId", model.UId)
         );
     return res == null ? 0 : Convert.ToInt32(res);
 }
コード例 #2
0
 /// <summary>
 /// 根据主键ID更新一条记录
 /// </summary>
 /// <param name="model">更新后的实体</param>
 /// <returns>执行结果受影响行数</returns>
 public int Update(PictureInfoModel model)
 {
     return _dao.Update(model);
 }
コード例 #3
0
 /// <summary>
 /// 向数据库中添加一条记录
 /// </summary>
 /// <param name="model">要添加的实体</param>
 /// <returns>插入数据的ID</returns>
 public int Insert(PictureInfoModel model)
 {
     return _dao.Insert(model);
 }
コード例 #4
0
 /// <summary>
 /// 根据主键ID更新一条记录
 /// </summary>
 /// <param name="model">更新后的实体</param>
 /// <returns>执行结果受影响行数</returns>
 public int Update(PictureInfoModel model)
 {
     #region SQL语句
     const string sql = @"
     UPDATE [dbo].[PictureInfo]
     SET
     [LargeImgPath] = @LargeImgPath
     ,[UploadDate] = @UploadDate
     ,[Width] = @Width
     ,[Height] = @Height
     ,[ImgSummary] = @ImgSummary
     ,[CollectCount] = @CollectCount
     ,[UId] = @UId
     WHERE [PId] = @PId";
     #endregion
     return SqlHelper.ExecuteNonQuery(sql,
             new SqlParameter("@PId", model.PId),
             new SqlParameter("@LargeImgPath", model.LargeImgPath),
             new SqlParameter("@UploadDate", model.UploadDate),
             new SqlParameter("@Width", model.Width),
             new SqlParameter("@Height", model.Height),
             new SqlParameter("@ImgSummary", model.ImgSummary),
             new SqlParameter("@CollectCount", model.CollectCount),
             new SqlParameter("@UId", model.UId)
         );
 }