Example #1
0
        public void Init()
        {
            MongoDBHelper helper = new MongoDBHelper("MongoDBTesting", "mongodb://*****:*****@localhost");

            manager = helper.GetDataManager <MongoEntity>();
            MongoEntity entity = new MongoEntity {
                备注 = "hello"
            };
            MongoEntity queryentity = new MongoEntity {
                备注 = "query1"
            };

            queryentity.列表 = new List <MongoEntity>()
            {
                new MongoEntity {
                    备注 = "hello query1", 列表 = new List <MongoEntity>()
                    {
                        new MongoEntity {
                            备注 = "subsub1 query"
                        },
                        new MongoEntity {
                            备注 = "subsub2 query"
                        }
                    }
                },
                new MongoEntity {
                    备注 = "world query2"
                },
            };
            manager.Insert(new MongoEntity[] { entity, queryentity });
        }
Example #2
0
        public void TestMongoRemove()
        {
            MongoEntity entity = new MongoEntity {
                备注 = "remove1"
            };

            manager.Insert(entity);
            manager.Delete(new { 备注 = "remove1" });
            Assert.IsNull(manager.FindOne(new { 备注 = "remove1" }));
        }
Example #3
0
        public void TestMongoInsert()
        {
            MongoEntity entity = new MongoEntity {
                备注 = "insert1"
            };

            manager.Insert(new MongoEntity[] { entity });
            var query = new Expando();

            query["_id"] = entity.Id;
            Assert.IsNotNull(manager.FindOne(query));
            manager.Delete(query);
        }