public void CreateQuery_WithFunctionAndDifferentExpressions_QueryCreatedAsExpected() { const string expectedQueryString = "SELECT { [Dim Hierarchy].[Dim] } ON Columns " + "FROM [Cube] " + "WHERE { ( { FILTER([Dim Hierarchy].[Dim].[Dim Key], { [Dim Hierarchy].[Dim].[Dim Key] }) } ) }"; var query = Mdx.Query() .On(Mdx.Axis().WithSlicer(Mdx.Tuple().With(Mdx.Member("Dim Hierarchy", "Dim")))) .From(Mdx.Cube("Cube")) .Where(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"))))); query.ToString().Should().Be(expectedQueryString); }
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); }