public virtual PollAnswer UpdatePollAnswer(PollAnswer entity) { if (entity.IsTransient()) { return(entity); } PollAnswer other = GetPollAnswer(entity.PollAnswerId); if (entity.Equals(other)) { return(entity); } string sql = @"Update PollAnswer set [PollAnswerGUID]=@PollAnswerGUID , [PollID]=@PollID , [Name]=@Name , [DisplayOrder]=@DisplayOrder , [ExtensionData]=@ExtensionData , [Deleted]=@Deleted , [CreatedOn]=@CreatedOn where PollAnswerID=@PollAnswerID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@PollAnswerID", entity.PollAnswerId) , new SqlParameter("@PollAnswerGUID", entity.PollAnswerGuid) , new SqlParameter("@PollID", entity.PollId) , new SqlParameter("@Name", entity.Name) , new SqlParameter("@DisplayOrder", entity.DisplayOrder) , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value) , new SqlParameter("@Deleted", entity.Deleted) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetPollAnswer(entity.PollAnswerId)); }
public virtual PollAnswer InsertPollAnswer(PollAnswer entity) { PollAnswer other = new PollAnswer(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into PollAnswer ( [PollAnswerGUID] ,[PollID] ,[Name] ,[DisplayOrder] ,[ExtensionData] ,[Deleted] ,[CreatedOn] ) Values ( @PollAnswerGUID , @PollID , @Name , @DisplayOrder , @ExtensionData , @Deleted , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@PollAnswerID", entity.PollAnswerId) , new SqlParameter("@PollAnswerGUID", entity.PollAnswerGuid) , new SqlParameter("@PollID", entity.PollId) , new SqlParameter("@Name", entity.Name) , new SqlParameter("@DisplayOrder", entity.DisplayOrder) , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value) , new SqlParameter("@Deleted", entity.Deleted) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetPollAnswer(Convert.ToInt32(identity))); } return(entity); }