-
-
Save jeffrymorris/3de0c2bb1593b84f3c63ef30bd522233 to your computer and use it in GitHub Desktop.
C# delegates example of sub-doc
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
//On the document itself | |
var results1 = doc.Mutate(mutator => | |
{ | |
mutator.Insert("toes", 4); | |
mutator.Replace("toes", 8); | |
mutator.Upsert("eyes", "blue"); | |
}); | |
//On a collection | |
var results2 = col.Mutate("theKey", mutator => | |
{ | |
mutator.Insert("toes", 4); | |
mutator.Replace("toes", 8); | |
mutator.Upsert("eyes", "blue"); | |
}); | |
//get from a document | |
var results3 = doc.Access(accessor => | |
{ | |
accessor.Count("somearraything"); | |
accessor.Get<string>("eyes"); | |
accessor.Get<int>("toes"); | |
accessor.Exists("bar"); | |
}); | |
//get from a collection | |
var results4 = col.Access("thekey", accessor => | |
{ | |
accessor.Count("somearraything"); | |
accessor.Get<string>("eyes"); | |
accessor.Get<int>("toes"); | |
accessor.Exists("bar"); | |
}); | |
var results3 = doc.Access(x => | |
{ | |
x.Count("somearraything"); | |
x.Get<string>("eyes"); | |
x.Get<int>("toes"); | |
x.Exists("bar"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment