/// <summary> /// 根据主键ID更新一条记录 /// </summary> /// <param name="model">更新后的实体</param> /// <returns>执行结果受影响行数</returns> public int Update(Model.Contacts model) { #region SQL语句 const string sql = @" UPDATE [dbo].[Contacts] SET [UserName] = @UserName ,[Tel] = @Tel ,[Tel1] = @Tel1 ,[Address] = @Address WHERE [Id] = @Id"; #endregion using (SqlConnection connection = new SqlConnection(connstr)) { return(connection.Execute(sql, model)); } }
/// <summary> /// 向数据库中添加一条记录 /// </summary> /// <param name="model">要添加的实体</param> /// <returns>插入数据的ID</returns> public int Insert(Model.Contacts model) { #region SQL语句 const string sql = @" INSERT INTO [dbo].[Contacts] ( [UserName] ,[Tel] ,[Tel1] ,[Address] ) VALUES ( @UserName ,@Tel ,@Tel1 ,@Address );select @@IDENTITY"; #endregion using (SqlConnection connection = new SqlConnection(connstr)) { return(connection.Execute(sql, model)); } }
/// <summary> /// 根据主键ID更新一条记录 /// </summary> /// <param name="model">更新后的实体</param> /// <returns>执行结果受影响行数</returns> public int Update(Model.Contacts model) { return(_dao.Update(model)); }
/// <summary> /// 向数据库中添加一条记录 /// </summary> /// <param name="model">要添加的实体</param> /// <returns>插入数据的ID</returns> public int Insert(Model.Contacts model) { return(_dao.Insert(model)); }