Skip to content

Instantly share code, notes, and snippets.

@Aaronontheweb
Created September 11, 2012 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aaronontheweb/3701389 to your computer and use it in GitHub Desktop.
Save Aaronontheweb/3701389 to your computer and use it in GitHub Desktop.
Sharding Models
var shards = new Dictionary<string, IDocumentStore>
{
{"Shard0", new DocumentStore {Url = "http://localhost:8080"}},
{"Shard1", new DocumentStore {Url = "http://localhost:8081"}},
{"Shard2", new DocumentStore {Url = "http://localhost:8082"}},
};
var shardStrategy = new ShardStrategy(shards)
.ShardingOn<FoodOrder>(order => order.CustomerId);
var documentStore = new ShardedDocumentStore(shardStrategy).Initialize();
public class Customer{
public string Id {get;set;}
public string Email {get;set;}
}
public class FoodOrder{
public string Id {get;set;}
public DateTime DateOrdered {get;set;}
public string CustomerId {get;set;}
//IDs for food items ordered
public List<string> OrderItems
{get;set;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment