public long InsertUser(UserEntity entity) { var dbCommand = DB.GetStoredProcCommand("spA_User_i"); AddInParameter(dbCommand, entity, false); DB.AddOutParameter(dbCommand, "@UserId", DbType.Int64, 8); DB.ExecuteNonQuery(dbCommand); entity.UserId = DbHelper.ConvertTo<long>(DB.GetParameterValue(dbCommand, "@UserId")); return entity.UserId; }
protected void AddInParameter(DbCommand command, UserEntity entity, bool containsPrimaryKey) { DB.AddInParameter(command, "@UserName", DbType.String, entity.UserName); DB.AddInParameter(command, "@CreateTime", DbType.DateTime, entity.CreateTime); DB.AddInParameter(command, "@UpdateTime", DbType.DateTime, entity.UpdateTime); if (containsPrimaryKey) { DB.AddInParameter(command, "@UserId", DbType.Int64, entity.UserId); } }
public void DeleteUser(UserEntity entity) { var command = DB.GetStoredProcCommand("spA_User_d"); DB.AddInParameter(command, "@UserId", DbType.Int64, entity.UserId); DB.ExecuteNonQuery(command); }
public bool UpdateUser(UserEntity entity) { var dbCommand = DB.GetStoredProcCommand("spA_User_u"); AddInParameter(dbCommand, entity, true); return DbHelper.ConvertTo<int>(DB.ExecuteScalar(dbCommand)) == 0; }
public void DeleteUser(UserEntity entity) { userInsertDB.DeleteUser(entity); }
public bool UpdateUser(UserEntity entity) { return userInsertDB.UpdateUser(entity); }
public long AddUser(UserEntity entity) { return userInsertDB.InsertUser(entity); }