Exemple #1
0
        internal MdxSelectStatement GenerateCurrentStatement(MdxQueryContext MdxQueryContext)
        {
            var newAxes = Axes;

            for (int i = 0; i < Axes.Count; i++)
            {
                var axis    = Axes[i];
                var cntAxis = MdxQueryContext.Axes[i];
                var newAxis = axis.GenerateCurrentAxis(cntAxis);
                if (!object.ReferenceEquals(axis, newAxis))

                {
                    if (newAxes == Axes)
                    {
                        newAxes = (MdxObjectList <MdxAxis>)Axes.Clone();
                    }

                    newAxes[i] = newAxis;
                }
            }
            if (newAxes == Axes)
            {
                return(this);
            }

            var result = new MdxSelectStatement(With, newAxes, Where, CubeSpecification);

            return(result);
        }
Exemple #2
0
 public MdxQueryContext(MdxSelectStatement OriginalStatement)
 {
     this.OriginalStatement = OriginalStatement;
     foreach (var Axis in OriginalStatement.Axes)
     {
         Axes.Add(new AxisInfo());
     }
 }
		public MdxQueryContext(MdxSelectStatement OriginalStatement)
		{
			this.OriginalStatement=OriginalStatement;
			foreach(var Axis in OriginalStatement.Axes)
			{
				Axes.Add(new AxisInfo());
			}
		}
Exemple #4
0
 public MdxSelectStatement(
     IEnumerable <MdxWithClauseItem> with,
     IEnumerable <MdxAxis> axes,
     MdxWhereClause where,
     MdxSelectStatement subSelect)
     : this()
 {
     if (with != null)
     {
         With.AddRange(with);
     }
     if (axes != null)
     {
         Axes.AddRange(axes);
     }
     m_Where     = where;
     m_SubSelect = subSelect;
 }
Exemple #5
0
        public override object Clone()
        {
            if (m_SubSelect != null)
            {
                var res =
                    new MdxSelectStatement(
                        (IEnumerable <MdxWithClauseItem>) this.With.Clone(),
                        (IEnumerable <MdxAxis>) this.Axes.Clone(),
                        this.Where != null ? (MdxWhereClause)this.Where.Clone() : null,
                        (MdxSelectStatement)this.SubSelect.Clone());
                res.CellProperties.AddRange((IEnumerable <MdxExpression>) this.CellProperties.Clone());

                return(res);
            }
            var res2 = new MdxSelectStatement(
                (IEnumerable <MdxWithClauseItem>) this.With.Clone(),
                (IEnumerable <MdxAxis>) this.Axes.Clone(),
                this.Where != null ? (MdxWhereClause)this.Where.Clone() : null,
                (MdxObjectReferenceExpression)this.Cube.Clone());

            res2.CellProperties.AddRange((IEnumerable <MdxExpression>) this.CellProperties.Clone());

            return(res2);
        }
		internal MdxSelectStatement GenerateCurrentStatement(MdxQueryContext MdxQueryContext)
		{
			var newAxes=Axes;
			
			for(int i=0;i<Axes.Count;i++)
			{
				var axis = Axes[i];
				var cntAxis=MdxQueryContext.Axes[i];
				var newAxis = axis.GenerateCurrentAxis(cntAxis);
				if (!object.ReferenceEquals(axis,newAxis))
				
				{
					if (newAxes==Axes)
						newAxes = (MdxObjectList<MdxAxis>)Axes.Clone();

					newAxes[i] = newAxis;
				}
			}
			if (newAxes==Axes)
				return this;
				
			var result=new MdxSelectStatement(With,newAxes,Where,CubeSpecification);
			return result;
		}
		public override object Clone()
		{
			if (m_SubSelect != null)
			{
                var res = 
                new MdxSelectStatement(
                        (IEnumerable<MdxWithClauseItem>)this.With.Clone(),
                        (IEnumerable<MdxAxis>)this.Axes.Clone(),
                        this.Where != null ? (MdxWhereClause)this.Where.Clone() : null,
                        (MdxSelectStatement)this.SubSelect.Clone());
                res.CellProperties.AddRange((IEnumerable<MdxExpression>)this.CellProperties.Clone());

                return res;
			}
            var res2 = new MdxSelectStatement(
                    (IEnumerable<MdxWithClauseItem>)this.With.Clone(),
                    (IEnumerable<MdxAxis>)this.Axes.Clone(),
                    this.Where != null ? (MdxWhereClause)this.Where.Clone() : null,
                    (MdxObjectReferenceExpression)this.Cube.Clone());
            res2.CellProperties.AddRange((IEnumerable<MdxExpression>)this.CellProperties.Clone());

            return res2;
		}
		public MdxSelectStatement(
				IEnumerable<MdxWithClauseItem> with,
				IEnumerable<MdxAxis> axes,
				MdxWhereClause where,
				MdxSelectStatement subSelect)
			: this()
		{
			if (with != null)
			{
				With.AddRange(with);
			}
			if (axes != null)
			{
				Axes.AddRange(axes);
			}
			m_Where = where;
			m_SubSelect = subSelect;
		}
        private MdxSelectStatement CreateWrappedStatement()
        {
            if (!string.IsNullOrEmpty(Query) && m_OriginalStatement == null)
            {
                using (MdxDomProvider provider = MdxDomProvider.CreateProvider())
                {
                    m_OriginalStatement = provider.ParseMdx(this.Query) as MdxSelectStatement;
                }
            }

            MdxSelectStatement select = null;
            try
            {
                if (m_OriginalStatement != null)
                {
                    select = m_OriginalStatement.Clone() as MdxSelectStatement; // (MdxSelectStatement)Serializer.Deserialize(Serializer.Serialize(m_OriginalStatement));
                    if (select != null)
                    {
                        if (History.CurrentHistoryItem != null)
                        {
                            if (select.Axes.Count > 0)
                            {
                                select.Axes[0] = GetWrappedAxis(select.Axes[0], History.CurrentHistoryItem.ColumnsActionChain);
                                if (select.Axes.Count > 1)
                                {
                                    select.Axes[1] = GetWrappedAxis(select.Axes[1], History.CurrentHistoryItem.RowsActionChain);
                                }

                                // Переворот осей
                                if (RotateAxes)
                                {
                                    if (select.Axes.Count > 1)
                                    {
                                        MdxExpression axis0_expression = select.Axes[0].Expression;
                                        select.Axes[0].Expression = select.Axes[1].Expression;
                                        select.Axes[1].Expression = axis0_expression;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return select;
        }