public void SimpleWay() { var axisSlicerMember = new MdxMember(); axisSlicerMember.Titled("Dim Hierarchy", "Dim"); var axisSlicer = new MdxTuple(); axisSlicer.With(axisSlicerMember); var axis = new MdxAxis(); axis.Titled(MdxAxisType.Columns); axis.AsNonEmpty(); axis.WithSlicer(axisSlicer); var cube = new MdxCube(); cube.Titled("Cube"); var querySlicerMember = new MdxMember(); querySlicerMember.Titled("Dim Hierarchy", "Dim", "Dim Key"); querySlicerMember.WithValue("1"); var querySlicer = new MdxTuple(); querySlicer.With(querySlicerMember); var query = new MdxQuery(); query.On(axis); query.From(cube); query.Where(querySlicer); }
internal MdxAxis GetWrappedAxis(MdxAxis ax /*, Func<MdxObject, MdxActionContext, MdxObject> ConcretizeMdxObject */) { MdxExpression axisExpression = ax.Expression; // 1. Если первым на оси стоит ключевое слово NON EMPTY то выражение формируем из его аргументов, а уже потом все это выражение обрамляем ключевым словом NON EMPTY // 2. Если запрос на оси обрамлен функцией HIERARCHIZE, то выражение формируем из ее аргумента, а уже потом все это выражение обрамляем функцией HIERARCHIZE /* * Флаг NonEmpty перенесен в MdxAxis. Проверок не требуется. * * MdxNonEmptyExpression nonEmpty = ax.Expression as MdxNonEmptyExpression; * if (actions != null && actions.Count > 0) * { * if (nonEmpty != null) * { * MdxExpression expression = nonEmpty.Expression; * MdxFunctionExpression hierarchize = expression as MdxFunctionExpression; * if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1) * { * expression = hierarchize.Arguments[0]; * } * * axisExpression = new MdxNonEmptyExpression( * new MdxFunctionExpression("HIERARCHIZE", * new MdxExpression[] * { * GetWrappedExpression(expression, actions) * })); * } * else * { * MdxExpression expression = ax.Expression; * MdxFunctionExpression hierarchize = expression as MdxFunctionExpression; * if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1) * { * expression = hierarchize.Arguments[0]; * } * * axisExpression = new MdxFunctionExpression( * "HIERARCHIZE", * new MdxExpression[] * { * GetWrappedExpression(expression, actions) * }); * } * } */ if (Actions.Count > 0) { var expression = ax.Expression; axisExpression = this.GetWrappedExpression(expression /*, ConcretizeMdxObject*/); } axisExpression = SortExpression(axisExpression, MeasuresSort); return(new MdxAxis( ax.Name, axisExpression, ax.Having, ax.DimensionProperties ) { // Возможность убрать пустые колонки NonEmpty = HideEmpty }); }
private MdxAxis GetWrappedAxis(MdxAxis ax, IList <DrillActionContainer> actions) { MdxExpression axisExpression = ax.Expression; // 1. Если первым на оси стоит ключевое слово NON EMPTY то выражение формируем из его аргументов, а уже потом все это выражение обрамляем ключевым словом NON EMPTY // 2. Если запрос на оси обрамлен функцией HIERARCHIZE, то выражение формируем из ее аргумента, а уже потом все это выражение обрамляем функцией HIERARCHIZE /* * Флаг NonEmpty перенесен в MdxAxis. Проверок не требуется. * * MdxNonEmptyExpression nonEmpty = ax.Expression as MdxNonEmptyExpression; * if (actions != null && actions.Count > 0) * { * if (nonEmpty != null) * { * MdxExpression expression = nonEmpty.Expression; * MdxFunctionExpression hierarchize = expression as MdxFunctionExpression; * if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1) * { * expression = hierarchize.Arguments[0]; * } * * axisExpression = new MdxNonEmptyExpression( * new MdxFunctionExpression("HIERARCHIZE", * new MdxExpression[] * { * GetWrappedExpression(expression, actions) * })); * } * else * { * MdxExpression expression = ax.Expression; * MdxFunctionExpression hierarchize = expression as MdxFunctionExpression; * if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1) * { * expression = hierarchize.Arguments[0]; * } * * axisExpression = new MdxFunctionExpression( * "HIERARCHIZE", * new MdxExpression[] * { * GetWrappedExpression(expression, actions) * }); * } * } */ if (actions.Count > 0) { var expression = ax.Expression; var hierarchize = expression as MdxFunctionExpression; if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1) { expression = hierarchize.Arguments[0]; } axisExpression = new MdxFunctionExpression( "HIERARCHIZE", new MdxExpression[] { GetWrappedExpression(expression, actions) }); } // Возможность убрать пустые колонки /* * if (nonEmpty == null && actions == History.CurrentHistoryItem.ColumnsActionChain && HideEmptyColumns) * { * axisExpression = new MdxNonEmptyExpression(axisExpression); * } */ // Возможность убрать пустые строки /* * if (nonEmpty == null && actions == History.CurrentHistoryItem.RowsActionChain && HideEmptyRows) * { * axisExpression = new MdxNonEmptyExpression(axisExpression); * } */ if (History.CurrentHistoryItem.ColumnsActionChain.Equals(actions) && HideEmptyColumns) { ax.NonEmpty = true; } if (History.CurrentHistoryItem.RowsActionChain.Equals(actions) && HideEmptyRows) { ax.NonEmpty = true; } return(new MdxAxis( ax.Name, axisExpression, ax.Having, ax.DimensionProperties ) { NonEmpty = ax.NonEmpty }); }
// $ANTLR end "compound_id" // $ANTLR start "axis_specification" // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:162:1: axis_specification returns [MdxAxis value] : ( NON EMPTY )? expression ( ( DIMENSION )? PROPERTIES p1= property ( ',' p2= property )* )? ON an= axis_name ; public MdxAxis axis_specification() // throws RecognitionException [1] { MdxAxis value = default(MdxAxis); MdxExpression p1 = default(MdxExpression); MdxExpression p2 = default(MdxExpression); string an = default(string); MdxExpression expression14 = default(MdxExpression); try { // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:163:2: ( ( NON EMPTY )? expression ( ( DIMENSION )? PROPERTIES p1= property ( ',' p2= property )* )? ON an= axis_name ) // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:163:4: ( NON EMPTY )? expression ( ( DIMENSION )? PROPERTIES p1= property ( ',' p2= property )* )? ON an= axis_name { bool NonEmpty=false; // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:164:2: ( NON EMPTY )? int alt19 = 2; int LA19_0 = input.LA(1); if ( (LA19_0 == NON) ) { alt19 = 1; } switch (alt19) { case 1 : // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:164:3: NON EMPTY { Match(input,NON,FOLLOW_NON_in_axis_specification765); Match(input,EMPTY,FOLLOW_EMPTY_in_axis_specification767); NonEmpty=true; } break; } PushFollow(FOLLOW_expression_in_axis_specification776); expression14 = expression(); state.followingStackPointer--; value = new MdxAxis(null, expression14, null, null); value.NonEmpty=NonEmpty; // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:170:3: ( ( DIMENSION )? PROPERTIES p1= property ( ',' p2= property )* )? int alt22 = 2; int LA22_0 = input.LA(1); if ( (LA22_0 == PROPERTIES || LA22_0 == DIMENSION) ) { alt22 = 1; } switch (alt22) { case 1 : // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:170:4: ( DIMENSION )? PROPERTIES p1= property ( ',' p2= property )* { // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:170:4: ( DIMENSION )? int alt20 = 2; int LA20_0 = input.LA(1); if ( (LA20_0 == DIMENSION) ) { alt20 = 1; } switch (alt20) { case 1 : // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:170:4: DIMENSION { Match(input,DIMENSION,FOLLOW_DIMENSION_in_axis_specification784); } break; } Match(input,PROPERTIES,FOLLOW_PROPERTIES_in_axis_specification787); PushFollow(FOLLOW_property_in_axis_specification791); p1 = property(); state.followingStackPointer--; if(value!=null) value.DimensionProperties.Add(p1); // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:171:5: ( ',' p2= property )* do { int alt21 = 2; int LA21_0 = input.LA(1); if ( (LA21_0 == 58) ) { alt21 = 1; } switch (alt21) { case 1 : // D:\\tfs\\Ranet.UILibrary.OLAP4\\trunk\\UILibrary.Olap\\Ranet.Olap.Mdx\\Compiler\\Parser\\mdx.g:171:7: ',' p2= property { Match(input,58,FOLLOW_58_in_axis_specification801); PushFollow(FOLLOW_property_in_axis_specification805); p2 = property(); state.followingStackPointer--; if(value!=null) value.DimensionProperties.Add(p2); } break; default: goto loop21; } } while (true); loop21: ; // Stops C# compiler whining that label 'loop21' has no statements } break; } Match(input,ON,FOLLOW_ON_in_axis_specification819); PushFollow(FOLLOW_axis_name_in_axis_specification823); an = axis_name(); state.followingStackPointer--; value.Name=an; } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { } return value; }