public void GetFromMongoTest()
        {
            var parser = new FilterParser();

            var result = parser.Parse(this.jobj);
//            var result = parser.Parse(jobj0);
//            var result = parser.Parse(jobj1);
//            var result = parser.Parse(jobj2);
//            var result = parser.Parse(jobj3);

            var builder = new MongoFilterBuilder <BsonDocument>();

            var text = result.GetQueryLanguageString();

            result.ConvertIdToMasterId();

            var mongoDataProvider = new MongoDataProvider("mongodb://demo.mongo1.domination.win:27017/masterdb_db9e00fa_1e68_4663_9bc2_93c7d7794b17");
            var collection        = mongoDataProvider.GetCollection <BsonDocument>("transactions");

            var documentsFinder = builder.RenderQuery(result, collection);

            var documents = documentsFinder.ToList();


            var q = new QueryLanguageBuilder().RenderQuery(result);
        }
Beispiel #2
0
        public void MongoFilterBuilderTest()
        {
            // var query = @"$jobj.job().ee.Pickup<>().ae.notes<general>()._Add(vx.dataAdded = 'xxx', md()._add(vx.text = 'zzz'))";
//            var query = @"$jobj.job(ae.instructions<driver>() && hd.tags(vx.name = 'jahahah') && ae.instructions<driver>().ae.comments<early>(vx.isRead = 'true'))";
            // var query = @"$jobj.job(ae.instructions<driver>().ae.comments<early>(vx.isRead = 'true') && ae.instructions<driver>().md.company<shipper>(vx.name = 'GE Transportation'))";
            //var query = @"$jobj.user(vx.firstName = 'New' && (id = 'f90d36be-7d10-4ed1-9753-5ea7ea87ea46' || vx.lastName = 'Name1'))";
            var query   = @"$jobj.user(vmd.user<driver>.vx.text = 'xxx')";
            var builder = new MongoFilterBuilder <BsonDocument>();


//            var mongoDataProvider = new MongoDataProvider("mongodb://dmz.mongo1.test.domination.win:27017/main");
            var mongoDataProvider = new MongoDataProvider("mongodb://demo.mongo1.domination.win:27017/masterdb_d00ffca1_07ad_4c0a_a984_89f6a7a75d15");
            var collection        = mongoDataProvider.GetCollection <BsonDocument>("transactions");

            var documentsFinder = builder.Build(query, collection);

            var documents = documentsFinder.ToList();

            JsonConvert.DefaultSettings = () =>
            {
                var defaultSettings = new JsonSerializerSettings();
//                defaultSettings.Converters.Add(new ObjectIdConverter());
                defaultSettings.Converters.Add(new BsonObjectIdConverter());
//                defaultSettings.Converters.Add(new DotInNamesConverter());
                return(defaultSettings);
            };


            var y = JsonConvert.DeserializeObject <JObject>(documents[0].ToJson());


            Console.WriteLine(documents);
        }
        public void Test()
        {
            var mongoProvider = new MongoDataProvider("mongodb://dmz.mongo1.test.domination.win:27017/test");
            var coll          = mongoProvider.GetCollection <BsonDocument>("testCollection");

            coll.InsertOne(new BsonDocument());
        }
Beispiel #4
0
        public void JsonModificationTests()
        {
            var json = @"{ 'z.z' : 1 }";


            var jobj = JsonConvert.DeserializeObject <JObject>(json);



            var ss = new JsonSerializerSettings();
//            ss.Converters.Add(new DotInNamesConverter());
            var mJobj = JsonConvert.SerializeObject(jobj, ss);

            var bson = BsonDocument.Parse(mJobj);

            var mongoDataProvider = new MongoDataProvider("mongodb://dmz.mongo1.test.domination.win:27017/test");
            var collection        = mongoDataProvider.GetCollection <BsonDocument>("test");

            collection.InsertOne(bson);

            //            var ser = JsonConvert.SerializeObject(), Formatting.Indented, new JsonSerializerSettings {ContractResolver = new ShouldSerializeContractResolver()});
        }