public void Lookup() { string projectId = _fixture.ProjectId; string namespaceId = _fixture.NamespaceId; // Snippet: Lookup(Key[]) DatastoreDb db = DatastoreDb.Create(projectId, namespaceId); KeyFactory keyFactory = db.CreateKeyFactory("message"); Entity message = new Entity { Key = keyFactory.CreateIncompleteKey(), ["text"] = "Original" }; db.Insert(message); using (DatastoreTransaction transaction = db.BeginTransaction()) { // Look the message up at the start of the transaction Entity fetched1 = transaction.Lookup(message.Key); Console.WriteLine((string)fetched1["text"]); // "Original" // Update the message outside the transaction message["text"] = "Updated"; db.Update(message); // Look up the message up again. We are guaranteed not to see the // update because it occurred after the start of the transaction. Entity fetched2 = transaction.Lookup(message.Key); Console.WriteLine((string)fetched2["text"]); // Still "Original" } // End snippet }
public void Update() { string projectId = _fixture.ProjectId; string namespaceId = _fixture.NamespaceId; // Snippet: Update(Entity, CallSettings) DatastoreDb db = DatastoreDb.Create(projectId, namespaceId); KeyFactory keyFactory = db.CreateKeyFactory("book"); Entity book = new Entity { Key = keyFactory.CreateIncompleteKey(), ["author"] = "Harper Lee", ["title"] = "Tequila Mockingbird", ["publication_date"] = new DateTime(1960, 7, 11, 0, 0, 0, DateTimeKind.Utc), ["genres"] = new[] { "Southern drama", "Courtroom drama", "Bildungsroman" } }; db.Insert(book); // Correct the typo in memory book["title"] = "To Kill a Mockingbird"; // Then update the entity in Datastore db.Update(book); // End snippet var fetched = db.Lookup(book.Key); Assert.Equal("To Kill a Mockingbird", (string)fetched["title"]); }
//Main function static void Main() { KeyFactory _keyFactory = _db.CreateKeyFactory(entity_kind); //Use this code to CREATE a new KIND and KEY /*Entity task = new Entity() * { * Key = _db.CreateKeyFactory(entity_kind).CreateKey(entity_key), * ["UpdatedDate"] = currentDateTimeTimestampUTC * }; * * //Insert the new Entity to Datastore * task.Key = _db.Insert(task);*/ //Use this code to update a specific KIND and KEY Entity _sampleTask = new Entity() { Key = _keyFactory.CreateKey(entity_key), }; _sampleTask["UpdatedDate"] = currentDateTimeTimestampUTC; _db.Update(_sampleTask); Console.WriteLine("Application was executed!"); }
public void TestUpdate() { _db.Upsert(_sampleTask); // [START update] _sampleTask["priority"] = 5; _db.Update(_sampleTask); // [END update] Assert.Equal(_sampleTask, _db.Lookup(_sampleTask.Key)); }
public void Update(Item item) { _db.Update(item.ToEntity()); }
public void Update(Book book) { _db.Update(book.ToEntity()); }
public void Update(ImageMetaDeta image) { _db.Update(image.ToEntity()); }
public void Update(Place place) { _db.Update(place.ToEntity()); }
public void UpdateOwner(Owner owner) { db.Update(owner.ToEntity()); }
public long Update(T item) { _db.Update(item.ToEntity(_db.CreateKeyFactory(_kind))); return(item.Id); }
public void Update(Player player) { _db.Update(player.ToEntity()); }
public void Update(Movie movie) { _db.Update(movie.ToEntity()); }
public void UpdateDatastore(Entity aEntity) { datastore.Update(aEntity); }
public void Update(Team team) { _db.Update(team.ToEntity()); }
public void Update(Book book) { _db.Update(book); }