Skip to content

Instantly share code, notes, and snippets.

@ideaflare
Created June 6, 2016 17:44
Show Gist options
  • Select an option

  • Save ideaflare/db8898706e6aa227918c2751403fe5fb to your computer and use it in GitHub Desktop.

Select an option

Save ideaflare/db8898706e6aa227918c2751403fe5fb to your computer and use it in GitHub Desktop.
// arrange some guinea pig for testing
class Sheep
{
// public get & set used to read/write values
public string Name { get; set; }
public IceCream FavouriteIceCream { get; set; }
}
enum IceCream
{
Vanilla,
Strawberry
}
var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };
// save data locally
var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\");
// or over a network via REST API to WCF server *see usage section below*
var db = Embark.Client.GetNetworkDB("192.168.1.24", 8080);
// collections created on-the-fly if needed
var io = db.GetCollection<Sheep>("sheep");
// create
long id = io.Insert(pet);
// read
Sheep fluffy = io.Get(id);
// update
fluffy.FavouriteIceCream = IceCream.Strawberry;
bool fluffyNowLikesStrawberry = io.Update(id, fluffy);
// delete
bool hasSheepVanished = io.Delete(id);
// non-type specific if you want to mix Apples & Oranges objects in the same collection
var io = db["fruit"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment