public async Task Get()
        {
            UserRepAsync userRep = new UserRepAsync();
            List <User>  list    = await userRep.GetListAsync(limit : 1);

            User user = list.First();
            long id   = user.ID;

            user = await userRep.GetAsync(user.ID);

            Assert.AreEqual(user.ID, id);

            user = await userRep.GetAsync(x => x.Name == "aa");

            Assert.AreNotEqual(user, null);
            user = await userRep.GetAsync(x => x.Name == "aa", x => new { x.Name });

            Assert.AreNotEqual(user, null);
            user = await userRep.GetAsync(x => x.Name == "aa", x => new { x.CreateTime });

            Assert.AreNotEqual(user, null);

            user = await userRep.GetAsync(x => x.Name == "aa" && x.CreateTime > DateTime.Parse("2015/10/20"));

            Assert.AreNotEqual(user, null);
            Builders <User> .Filter.Eq("Name", "aa");

            var filter = UserRepAsync.Filter.Eq(x => x.Name, "aa") & UserRepAsync.Filter.Eq(x => x.ID, 123);

            UserRepAsync.Sort.Descending("_id");

            user = await userRep.GetAsync(Builders <User> .Filter.Eq("Name", "aa"), null, Builders <User> .Sort.Descending("_id"));

            Assert.AreNotEqual(user, null);

            user = await userRep.GetAsync(filter : Builders <User> .Filter.Eq("Name", "aa"), projection : Builders <User> .Projection.Include(x => x.Name));

            Assert.AreNotEqual(user, null);
        }
        public async Task GetList()
        {
            UserRepAsync userRep  = new UserRepAsync();
            List <User>  userList = null;

            userList = await userRep.GetListAsync(null);

            userList = await userRep.GetListAsync(x => x.ID > 3 && x.Name == "aa");

            userList = await userRep.GetListAsync(x => x.ID > 3 && x.Name == "aa", null, s => s.ID, SortType.Ascending);

            userList = await userRep.GetListAsync(filterExp : x => x.Name == "aa", includeFieldExp : x => new { x.CreateTime });

            userList = await userRep.GetListAsync(filter : Builders <User> .Filter.Eq("Name", "aa"), sort : Builders <User> .Sort.Descending("_id"));

            userList = await userRep.GetListAsync(filter : Builders <User> .Filter.Eq("Name", "aa"), projection : Builders <User> .Projection.Include(x => x.Name));
        }
Example #3
0
        public async Task Insert()
        {
            UserRepAsync userRep = new UserRepAsync();

            var a = await userRep.InsertAsync(new User()
            {
                Name = "ggg"
            });

            var b = await userRep.InsertAsync(new User()
            {
                Name = "BBB"
            });

            var c = await userRep.InsertAsync(new User()
            {
                Name = "CCC"
            });

            APILogRepository apilog = new APILogRepository();

            var d = await apilog.InsertAsync(new Entity.APILog()
            {
                APIName = "sdfsafd", CreateTime = DateTime.Now
            });

            var list = await userRep.GetListAsync(x => x.Name == "ggg");

            UserRepAsync up = new UserRepAsync();

            list = await up.GetListAsync(x => x.Name == "ggg");

            await apilog.CreateIndex();

            Assert.AreNotEqual(list.Count, 0);
        }