/// <summary> /// Add common parameters before calling a procedure /// </summary> /// <param name="cmd">command object, where parameters will be added</param> /// <param name="userMachineMapObject"></param> private void AddCommonParams(SqlCommand cmd, UserMachineMapBase userMachineMapObject) { AddParameter(cmd, pGuid(UserMachineMapBase.Property_OwnerId, userMachineMapObject.OwnerId)); AddParameter(cmd, pGuid(UserMachineMapBase.Property_MachineId, userMachineMapObject.MachineId)); AddParameter(cmd, pGuid(UserMachineMapBase.Property_LastUpdatedBy, userMachineMapObject.LastUpdatedBy)); AddParameter(cmd, pDateTime(UserMachineMapBase.Property_LastUpdatedDate, userMachineMapObject.LastUpdatedDate)); }
/// <summary> /// Fills UserMachineMap object /// </summary> /// <param name="userMachineMapObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> /// <param name="start">The ordinal position from which to start reading the reader</param> protected void FillObject(UserMachineMapBase userMachineMapObject, SqlDataReader reader, int start) { userMachineMapObject.Id = reader.GetInt32(start + 0); userMachineMapObject.OwnerId = reader.GetGuid(start + 1); userMachineMapObject.MachineId = reader.GetGuid(start + 2); userMachineMapObject.LastUpdatedBy = reader.GetGuid(start + 3); userMachineMapObject.LastUpdatedDate = reader.GetDateTime(start + 4); FillBaseObject(userMachineMapObject, reader, (start + 5)); userMachineMapObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; }
/// <summary> /// Updates UserMachineMap /// </summary> /// <param name="userMachineMapObject">Object to be updated</param> /// <returns>Number of rows affected</returns> public long Update(UserMachineMapBase userMachineMapObject) { try { SqlCommand cmd = GetSPCommand(UPDATEUSERMACHINEMAP); AddParameter(cmd, pInt32(UserMachineMapBase.Property_Id, userMachineMapObject.Id)); AddCommonParams(cmd, userMachineMapObject); long result = UpdateRecord(cmd); if (result > 0) { userMachineMapObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; } return(result); } catch (SqlException x) { throw new ObjectUpdateException(userMachineMapObject, x); } }
/// <summary> /// Inserts UserMachineMap /// </summary> /// <param name="userMachineMapObject">Object to be inserted</param> /// <returns>Number of rows affected</returns> public long Insert(UserMachineMapBase userMachineMapObject) { try { SqlCommand cmd = GetSPCommand(INSERTUSERMACHINEMAP); AddParameter(cmd, pInt32Out(UserMachineMapBase.Property_Id)); AddCommonParams(cmd, userMachineMapObject); long result = InsertRecord(cmd); if (result > 0) { userMachineMapObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; userMachineMapObject.Id = (Int32)GetOutParameter(cmd, UserMachineMapBase.Property_Id); } return(result); } catch (SqlException x) { throw new ObjectInsertException(userMachineMapObject, x); } }
/// <summary> /// Fills UserMachineMap object /// </summary> /// <param name="userMachineMapObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> protected void FillObject(UserMachineMapBase userMachineMapObject, SqlDataReader reader) { FillObject(userMachineMapObject, reader, 0); }