private static async Task CreateSampleData(GremlinGraphClient client) { Console.Write("Adding people..."); var bob = await client.Add(new Person { FirstName = "Bob", LastName = "Oak", Age = 33 }).SubmitAsync(); var eve = await client.Add(new Person { FirstName = "Eve", LastName = "Maple", Age = 29 }).SubmitAsync(); var tim = await client.Add(new Person { FirstName = "Tim", LastName = "Spruce", Age = 26 }).SubmitAsync(); var ned = await client.Add(new Person { FirstName = "Ned", LastName = "Hickory", Age = 37 }).SubmitAsync(); Console.WriteLine("Done."); Console.Write("Adding skills..."); var cook = await client.Add(new Skill { Name = "Cooking" }).SubmitAsync(); var juggle = await client.Add(new Skill { Name = "Juggle" }).SubmitAsync(); var sew = await client.Add(new Skill { Name = "Sew" }).SubmitAsync(); var changeLightbulb = await client.Add(new Skill { Name = "Change lightbulb" }).SubmitAsync(); var skateboard = await client.Add(new Skill { Name = "Skateboard" }).SubmitAsync(); Console.WriteLine("Done."); Console.Write("Adding relationships..."); await client.ConnectVerticies(bob, eve, "loves").SubmitAsync(); await client.ConnectVerticies(bob, tim, "likes").SubmitAsync(); await client.ConnectVerticies(eve, bob, "likes").SubmitAsync(); await client.ConnectVerticies(tim, eve, "hates").SubmitAsync(); await client.ConnectVerticies(ned, tim, "loves").SubmitAsync(); await client.ConnectVerticies(ned, eve, "loves").SubmitAsync(); await client.ConnectVerticies(bob, sew, "can").SubmitAsync(); await client.ConnectVerticies(bob, changeLightbulb, "can").SubmitAsync(); await client.ConnectVerticies(eve, juggle, "can").SubmitAsync(); await client.ConnectVerticies(eve, changeLightbulb, "can").SubmitAsync(); await client.ConnectVerticies(tim, cook, "can").SubmitAsync(); await client.ConnectVerticies(ned, sew, "can").SubmitAsync(); await client.ConnectVerticies(ned, changeLightbulb, "can").SubmitAsync(); await client.ConnectVerticies(ned, juggle, "can").SubmitAsync(); await client.ConnectVerticies(ned, skateboard, "can").SubmitAsync(); Console.WriteLine("Done."); }
static async Task MainAsync(string[] args) { var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); var settings = new GraphClientSettings(config); var client = new GremlinGraphClient(settings.Url, settings.Database, settings.Collection, settings.Password) { Logger = new GremlinLogger() }; var users = await client.From <User>().SubmitAsync(); Console.WriteLine(users.Count()); var user = await client .Add(new User() { Name = "John Doe" }) .SubmitAsync(); users = await client.From <User>().SubmitAsync(); Console.WriteLine(users.Count()); }