Esempio n. 1
0
        public void CreateQuery_WithDeclaredMemberAndSet_QueryCreatedAsExpected()
        {
            const string expectedQueryString = "WITH " +
                                               "MEMBER [MyMember] AS [Dim Hierarchy].[Dim] " +
                                               "SET [MySet] AS { FILTER([Dim Hierarchy].[Dim].[Dim Key], { [Dim Hierarchy].[Dim].[Dim Key] }) } " +
                                               "SELECT { [MyMember] } ON Columns " +
                                               "FROM [Cube] " +
                                               "WHERE { ( { ( [MySet] ) } ) }";

            var query = Mdx.Query()
                        .With(Mdx.DeclaredMember("MyMember").As(Mdx.Expression().WithOperand(Mdx.Member("Dim Hierarchy", "Dim"))))
                        .With(Mdx.DeclaredSet("MySet").As(Mdx.Tuple().With(Mdx.Function("FILTER")
                                                                           .WithParameters(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key"))
                                                                           .WithParameters(Mdx.Tuple().With(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key"))))))
                        .On(Mdx.Axis(0).WithSlicer(Mdx.Tuple().With(Mdx.Member("MyMember"))))
                        .From(Mdx.Cube("Cube"))
                        .Where(Mdx.Tuple().With(Mdx.Set().With(Mdx.Member("MySet"))));

            query.ToString().Should().Be(expectedQueryString);
        }