public void Lookup()
        {
            string projectId   = _fixture.ProjectId;
            string namespaceId = _fixture.NamespaceId;

            // Snippet: Lookup(*,*,*,*)
            KeyFactory keyFactory = new KeyFactory(projectId, namespaceId, "book");
            Key        key1       = keyFactory.CreateKey("pride_and_prejudice");
            Key        key2       = keyFactory.CreateKey("not_present");

            DatastoreClient client   = DatastoreClient.Create();
            LookupResponse  response = client.Lookup(
                projectId,
                new ReadOptions {
                ReadConsistency = ReadConsistency.Strong
            },
                new[] { key1, key2 });

            Console.WriteLine($"Found: {response.Found.Count}");
            Console.WriteLine($"Deferred: {response.Deferred.Count}");
            Console.WriteLine($"Missing: {response.Missing.Count}");
            // End snippet

            Entity entity = response.Found[0].Entity;

            Assert.Equal("Jane Austen", (string)entity["author"]);
            Assert.Equal("Pride and Prejudice", (string)entity["title"]);
        }
示例#2
0
 public void Lookup()
 {
     // Snippet: Lookup(string,ReadOptions,IEnumerable<Key>,CallSettings)
     // Create client
     DatastoreClient datastoreClient = DatastoreClient.Create();
     // Initialize request argument(s)
     string            projectId   = "";
     ReadOptions       readOptions = new ReadOptions();
     IEnumerable <Key> keys        = new List <Key>();
     // Make the request
     LookupResponse response = datastoreClient.Lookup(projectId, readOptions, keys);
     // End snippet
 }
 /// <summary>Snippet for Lookup</summary>
 public void Lookup_RequestObject()
 {
     // Snippet: Lookup(LookupRequest,CallSettings)
     // Create client
     DatastoreClient datastoreClient = DatastoreClient.Create();
     // Initialize request argument(s)
     LookupRequest request = new LookupRequest
     {
         ProjectId = "",
         Keys      = { },
     };
     // Make the request
     LookupResponse response = datastoreClient.Lookup(request);
     // End snippet
 }
        public void LookupEntity()
        {
            string projectId = _fixture.ProjectId;
            Key    key       = _fixture.LearnDatastoreKey;

            // Sample: LookupEntity
            DatastoreClient client   = DatastoreClient.Create();
            LookupResponse  response = client.Lookup(
                projectId,
                new ReadOptions {
                ReadConsistency = ReadConsistency.Eventual
            },
                new[] { key });

            Entity entity = response.Found[0].Entity;
            // End sample
        }