AzureTable.LiteClient - simple, complete and super fast Azure Table Storage client for .NET.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md

README.md

AzureTable.LiteClient - simple, complete and super fast Azure Table Storage client for .NET.

Unlike the official Azure Storage SDK for .NET, AzureTable.LiteClient has the following features:

  • full support for POCO
  • full support for dynamic and anonymous objects
  • PCL only (small footprint - ideal to be used with Xamarin)
  • minimal dependencies (only Newtosoft.Json), no OData dependencies

You can get the binaries from Nuget.

Get table reference

AzureTableClient tableClient = new AzureTableClient("yourAccountName", @"yourAccountKey");
AzureTable table = tableClient.GetTableReference("people");

Insert an Entity

TableResult result = await table.InsertAsync(new {PartitionKey="Harp",RowKey="jd_01",FirstName="John", LastName="Doe" });

or insert using a custom entity:

 public class Person
    {
        public string PartitionKey { get; set; }
        public string RowKey { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
Person p = new Person {PartitionKey="Harp",RowKey="jd_01",FirstName="John", LastName="Doe" };

TableResult result = await table.InsertAsync(p);

Note: every entity should have the PartitionKey and the RowKey properties, this is the only mandatory requirement.

Get the entity by PK and RK:

dynamic entity = await table.FindOneAsync("Harp","jd_01");

//or map it to your POCO
Person p = await table.FindOneAsync<Person>("Harp","jd_01");

Add new property value and keep existing properties and values:

dynamic entity = await table.FindOneAsync("Harp","jd_01");
entity.Email = "cristi@contoso.com";
var result=await table.MergeAsync(item);

Note: Azure Table Storage entities may have a dynamic number of properties. So one entity from a table may have 2 properties and other may have 3 (or more or less).

Query by other fields:

  IEnumerable<dynamic> allPersons = await table.FindAsync(filter: "FirstName eq 'John'");
       
 // or map it to custom POCOs
 IEnumerable<Person> allPersons = await table.FindAsync<Person>(filter: "FirstName eq 'John'");
                   
          

examples of other types or more complex queries:

//get all entities for WHERE PartitionKey="Harp" AND Age>30
string myFilter="PartitionKey eq 'Harp' and Age gt 30"
var items = await table.FindAsync<Person>(filter:myFilter);

//get by timestamp (WHERE Timestamp < now)

string myFilter = string.Format("Timestamp lt datetime'{0}'", DateTime.UtcNow.ToString("o", CultureInfo.InvariantCulture));

var items = await table.FindAsync<Person>(filter:myFilter);

The query syntax is based on the REST API, more info about the syntax can be found here. The filter string should NOT be URL encoded, the library encodes it for you.

FAQ

Q: How can I use this with Siaqodb?

A: Siaqodb has a module called SiaqodbCloud. As of version 5.5.0.10, the service has a new SiaqodbSync method tgat takes an AzureTableClient object to syncronize all objects to your database automatically.