This library uses the REST api against SQL Server Data Services and performs CRUD & Query operations. It features a powerful LINQ-based query and serialization model to make working with objects and SSDS very simple.
This updated release on 9/4 features new support for blobs, concurrency, and parallelism in addition the already powerful LINQ query support over strongly typed objects.
var container = Context.OpenContainer("querytests");
var foo = new Foo { IsPublic = false, Name = "MyFoo", Size = 12 };
//insert it with unique id guid string
container.Insert(foo, Guid.NewGuid().ToString());
//notice the LINQ syntax on strong type "Foo"
var results = container.Query<Foo>(e => e.Entity.Size > 2);
This release also supports blobs via the SsdsBlobEntity both synchronously as well as async
MemoryStream mem = new MemoryStream();
//load memory stream
//...
//now upload it to service
using (SsdsBlobEntity blob = new SsdsBlobEntity(mem))
{
blob.ContentDisposition = "violin.jpg";
blob.MimeType = @"image/jpeg";
blob.Id = Guid.NewGuid().ToString();
var container = Context.OpenContainer("blobtests");
container.Insert(blob);
}
Concurrency using If-Match and If-None-Match headers is supported as well.
var table = Context.OpenContainer("foo");
//create new foo
var foo = new Foo { IsPublic = false, Name = "Foo", Size = 10 };
string id = Guid.NewGuid().ToString();
table.Insert(foo, id);
//update entity if none match (different version)
SsdsEntity<Foo> entity = new SsdsEntity<Foo>();
entity.Entity = foo;
entity.Id = id;
entity.Entity.Name = "Foo2";
table.Update(entity, ConcurrencyPattern.IfNoneMatch);
This release also supports parallelism to the SSDS service using the Parallel Extensions. This support is extensible to other techniques using extension methods.
var container = Context.OpenContainer("paging");
List<SsdsEntity<Foo>> entities = new List<SsdsEntity<Foo>>();
for (int i = 0; i < 10; i++)
{
var foo = new Foo
{
IsPublic = false,
Name = "Foo" + i,
Size = i
};
entities.Add(new SsdsEntity<Foo>() { Entity = foo, Id = foo.Name });
}
Exception ex = null;
container.Insert<Foo>(entities, (ent, excep) =>
{
ex = excep;
return false;
});
if (ex != null)
{
throw ex;
}
More information about this provider can be found in the related blog postings:
Serialization in SSDSWorking with Objects in SSDS Part 1Working with Objects in SSDS Part 2Working with Objects in SSDS Part 3