Last active
December 15, 2015 12:28
-
-
Save plaurin/5260074 to your computer and use it in GitHub Desktop.
Document store implementation usages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Project | |
{ | |
public Guid Owner { get; set; } | |
public Guid Id { get; set; } | |
public string Name { get; set; } | |
public DateTime StartDate { get; set; } | |
public int Status { get; set; } | |
public List<Task> Tasks { get; set; } | |
} | |
public class Task | |
{ | |
public string Name { get; set; } | |
public bool IsCompleted { get; set; } | |
} | |
private void Insert() | |
{ | |
var repo = new ProjectRepository(); | |
var project = new Project() | |
{ | |
Owner = Guid.Parse("8ad82668-4b08-49c9-87ef-80870bfb4b85"); | |
Name = "My new project", | |
StartDate = DateTime.Now, | |
Status = 4, | |
Tasks = new List<Task>() | |
{ | |
new Task { Name = "Task 1", IsCompleted = true }, | |
new Task { Name = "Task 2" } | |
} | |
}; | |
repo.Insert(project); | |
} | |
private void List() | |
{ | |
var repo = new ProjectRepository(); | |
var projects = repo.List("static"); | |
projects.Dump(); | |
} | |
private void Load() | |
{ | |
var repo = new ProjectRepository(); | |
var project = repo.Load("8ad82668-4b08-49c9-87ef-80870bfb4b85", "c7d5f59c-72da-48de-83ca-265d8609ec02"); | |
project.Dump(); | |
} | |
private void Update() | |
{ | |
var repo = new ProjectRepository(); | |
var project = repo.Load("8ad82668-4b08-49c9-87ef-80870bfb4b85", "c7d5f59c-72da-48de-83ca-265d8609ec02"); | |
project.Name = "Modified name " + DateTime.Now.Ticks; | |
repo.Update(project); | |
} | |
private void Delete() | |
{ | |
var repo = new ProjectRepository(); | |
var project = repo.Load("8ad82668-4b08-49c9-87ef-80870bfb4b85", "c7d5f59c-72da-48de-83ca-265d8609ec02"); | |
repo.Delete(project); | |
} | |
private void DeleteDirectly() | |
{ | |
var repo = new ProjectRepository(); | |
repo.Delete("8ad82668-4b08-49c9-87ef-80870bfb4b85", "c7d5f59c-72da-48de-83ca-265d8609ec02"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment