示例#1
0
        public void SyncQueries_ImplicityUsePartition()
        {
            var db        = _fixture.CreateDatastoreDb();
            var parentKey = PrepareQueryTest(db);

            using (var transaction = db.BeginTransaction())
            {
                var query = new Query("childKind")
                {
                    Filter = Filter.HasAncestor(parentKey)
                };
                var gql = new GqlQuery
                {
                    QueryString        = "SELECT * FROM childKind WHERE __key__ HAS ANCESTOR @1",
                    PositionalBindings = { parentKey }
                };
                var lazyResults = transaction.RunQueryLazily(query);
                Assert.Equal(1, lazyResults.Count());
                lazyResults = transaction.RunQueryLazily(gql);
                Assert.Equal(1, lazyResults.Count());

                var eagerResults = transaction.RunQuery(query);
                Assert.Equal(1, eagerResults.Entities.Count);
                eagerResults = transaction.RunQuery(gql);
                Assert.Equal(1, eagerResults.Entities.Count);
            }
        }
        public void Lookup_FullPartition()
        {
            var db         = _fixture.CreateDatastoreDb();
            var keyFactory = db.CreateKeyFactory("test");
            var entity     = new Entity
            {
                Key     = keyFactory.CreateIncompleteKey(),
                ["foo"] = "bar"
            };
            var key = db.Insert(entity);

            var result = db.Lookup(key);

            Assert.NotNull(result);
            Assert.Equal("bar", (string)entity["foo"]);
        }