コード例 #1
0
        public virtual PollSection InsertPollSection(PollSection entity)
        {
            PollSection other = new PollSection();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into PollSection ( [PollID]
				,[SectionID]
				,[CreatedOn] )
				Values
				( @PollID
				, @SectionID
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@PollID", entity.PollId)
                    , new SqlParameter("@SectionID", entity.SectionId)
                    , 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(GetPollSection(Convert.ToInt32(identity)));
            }
            return(entity);
        }
コード例 #2
0
        public virtual PollSection PollSectionFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            PollSection entity = new PollSection();

            entity.PollId    = (System.Int32)dr["PollID"];
            entity.SectionId = (System.Int32)dr["SectionID"];
            entity.CreatedOn = (System.DateTime)dr["CreatedOn"];
            return(entity);
        }
コード例 #3
0
        public virtual PollSection UpdatePollSection(PollSection entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            PollSection other = GetPollSection(entity.PollId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update PollSection set  [SectionID]=@SectionID
							, [CreatedOn]=@CreatedOn 
							 where PollID=@PollID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@PollID", entity.PollId)
                , new SqlParameter("@SectionID", entity.SectionId)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetPollSection(entity.PollId));
        }
コード例 #4
0
 public PollSection InsertPollSection(PollSection entity)
 {
     return(_iPollSectionRepository.InsertPollSection(entity));
 }
コード例 #5
0
 public PollSection UpdatePollSection(PollSection entity)
 {
     return(_iPollSectionRepository.UpdatePollSection(entity));
 }
コード例 #6
0
 public virtual PollSection DeletePollSection(PollSection entity)
 {
     this.DeletePollSection(entity.PollId);
     return(entity);
 }