Pogo is an unofficial ORM for Google's Cloud Datastore (GCD). The API was inspired by the RavenDB client API.
Pogo is available on Nuget.
You can follow Google's instructions here
Pogo uses the standard config file connection strings:
<configuration>
<connectionStrings>
<add name="Pogo" connectionString="DatasetId = YOUR_DATASET_ID; CertificateFilePath = C:\Path\To\Your\Certificate\File-privatekey.p12; ServiceAccountId = your-service-account-email@developer.gserviceaccount.com; CertificatePassword = notasecret"/>
</connectionStrings>
</configuration>
DatasetId: GCD Dataset ID (same as Google Cloud Project ID)
CertificateFilePath: Path to the private key file generated from step 10 here
ServiceAccountId: The service account from step 11 here
CertificatePassword: The password to the certificate (usually "notasecret")
var datastore = new GoogleCloudDatastore("ConnStringName");
Pogo takes your plain-old objects and converts them to the Google Datastore format. Your object must have a key property named "Id" (not case sensitive).
var person = new TestPerson
{
Id = "TestPersons/99",
FirstName = "Rey",
HireDate = new DateTime(2012, 5, 7, 9, 30, 0),
HourlyRate = 25.0,
IsActive = true
};
using (var session = datastore.OpenSession())
{
session.Store(person);
session.SaveChanges();
}
using (var session = datastore.OpenSession())
{
var person = session.Load<TestPerson>("TestPersons/99");
}
All interactions with GCD happen within the context of a session. Pogo implements the Unit of Work pattern. If an object is retrieved within a session, modified, and SaveChanges is called, then those changes will be applied to the datastore.
GCD supports comparison operators (equal, less than, greater than, less than or equal, greater than or equal). Pogo supports LINQ and translates these queries into low-level GCD queries.
using (var session = datastore.OpenSession())
{
var results = session.Query<TestPerson>()
.Where(t => t.HourlyRate > 50.0)
.ToList();
}
All GCD queries use indexes. For basic queries, indexes are auto-generated. If inequality filters are applied to multiple properties, you need to explicitly create an index.
If GCD doesn't support auto-indexing for complex queries soon, then we will add index generation to Pogo. For now, you need to create manual indexes and publish them to GCD using the gcd tool.
See the CONTRIBUTING document.
Pogo is written and maintained by Samuel Nissim.
Pogo is free software, and may be redistributed under the terms specified in the LICENSE file.