Esempio n. 1
0
        private void GenerateQuery(RequiredDataContainer Container, string Database)
        {
            QueryableEntity Aluno    = new QueryableEntity(Container.EntityRelationshipModel.FindByName("Aluno"));
            QueryableEntity Endereco = new QueryableEntity(Container.EntityRelationshipModel.FindByName("Endereco"));

            RelationshipJoinOperator RJoinOp = new RelationshipJoinOperator(
                Aluno,
                (Relationship)Container.EntityRelationshipModel.FindByName("AlunoMora"),
                new List <QueryableEntity>()
            {
                Endereco
            },
                Container.ERMongoMapping);

            SortArgument SortArg = new SortArgument(Aluno, Aluno.Element.GetIdentifierAttribute(), MongoDBSort.Ascending);
            SortStage    SortOp  = new SortStage(new List <SortArgument>()
            {
                SortArg
            }, Container.ERMongoMapping);

            List <AlgebraOperator> OperatorList = new List <AlgebraOperator>()
            {
                RJoinOp, SortOp
            };

            FromArgument FromArg = new FromArgument(Aluno, Container.ERMongoMapping);

            QueryGenerator QueryGen = new QueryGenerator(FromArg, OperatorList);

            string Query = QueryGen.Run();

            Beautifier jsB = new Beautifier();

            queryBox.Text = jsB.Beautify(Query);

            QueryRunner QueryRunner = new QueryRunner("mongodb://localhost:27017", Database);

            string Result = QueryRunner.GetJSON(Query);

            resultBox.Text = Result.PrettyPrintJson();
        }