Operations on tables:

    var client = new CyanTableClient("my account", "account secret");

    // create a table
    client.TryCreateTable("MyTable");

    // enumerate tables
    var tables = client.QueryTables();

    // delete a table
    client.DeleteTable("MyTable");

Querying:

    var client = new CyanTableClient("my account", "account secret");

    // get an exact entity
    var exactEntity = client.Query("MyTable", "PartitionKey", "RowKey").First();

    // enumerate rows in a partition
    var partitionEntities = client.Query("MyTable", "PartitionKey");

    // get all entities matching the filter and with automatic continuation off
    var matchingEntities = client.Query("MyTable", filter: "MyField eq 1337", disableContinuation: true);

    // perform a glorious full table scan:)
    var fullScan = client.Query("MyTable");

Of course pagination is automatic, we don't like no stinkin' headers! (x-ms-continuation-*)

Inserting:

    var client = new CyanTableClient("my account", "account secret");

    var entity = client.Insert("MyTable", new
        {
            PartitionKey = "PartitionKey",
            RowKey = "RowKey",
            MyField = "foo bar",
            MyIntField = 1337
        });

Updating:

    var client = new CyanTableClient("my account", "account secret");

    var entity = client.Query("MyTable", "PartitionKey", "RowKey").First();

    entity.MyField = "new value";

    // optimistic concurrency is the default
    // you can turn it off calling client.Update("MyTable", entity, unconditionalUpdate: true);
    client.Update("MyTable", entity);

Deleting:

    var client = new CyanTableClient("my account", "account secret");

    var entity = client.Query("MyTable", "PartitionKey", "RowKey").First();

    // delete using an entity
    client.Delete("MyTable", entity);

    // delete with just partition and row keys
    client.Delete("MyTable", "PartitionKey", "RowKey");

Last edited Feb 24, 2012 at 6:31 AM by maghis, version 2

Comments

No comments yet.