Пример #1
0
        public virtual PollSortOrder UpdatePollSortOrder(PollSortOrder entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            PollSortOrder other = GetPollSortOrder(entity.PollSortOrderId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update PollSortOrder set  [PollSortOrderGUID]=@PollSortOrderGUID
							, [Name]=@Name
							, [DisplayOrder]=@DisplayOrder
							, [CreatedOn]=@CreatedOn 
							 where PollSortOrderID=@PollSortOrderID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@PollSortOrderID", entity.PollSortOrderId)
                , new SqlParameter("@PollSortOrderGUID", entity.PollSortOrderGuid)
                , new SqlParameter("@Name", entity.Name)
                , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetPollSortOrder(entity.PollSortOrderId));
        }
Пример #2
0
        public virtual PollSortOrder InsertPollSortOrder(PollSortOrder entity)
        {
            PollSortOrder other = new PollSortOrder();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into PollSortOrder ( [PollSortOrderGUID]
				,[Name]
				,[DisplayOrder]
				,[CreatedOn] )
				Values
				( @PollSortOrderGUID
				, @Name
				, @DisplayOrder
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@PollSortOrderID", entity.PollSortOrderId)
                    , new SqlParameter("@PollSortOrderGUID", entity.PollSortOrderGuid)
                    , new SqlParameter("@Name", entity.Name)
                    , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                    , 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(GetPollSortOrder(Convert.ToInt32(identity)));
            }
            return(entity);
        }