public static void CreateCategoryRoot(CategoryRoot objCategoryRoot) { Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod()); Logger.WriteObjectToLogFile <CategoryRoot>(objCategoryRoot); Neo4jController.m_graphClient.Cypher .Merge("(A:" + objCategoryRoot.getLabel() + "{ Name : {Name} })") .OnCreate() .Set("A = { objCategoryRoot }") .WithParams(new { Name = objCategoryRoot.Name, objCategoryRoot = objCategoryRoot }) .ExecuteWithoutResults(); }
public static void CreateCategoryNode(Category objCategory) { Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod()); Logger.WriteObjectToLogFile <Category>(objCategory); CategoryRoot objRoot = new CategoryRoot(); var result = Neo4jController.m_graphClient.Cypher .Merge("(A:" + objRoot.getLabel() + " { Name : {Name} })") .OnCreate() .Set("A = { objRoot }") .Merge("(A)-[R:" + Rel_CategoryRoot.categoryroot_category + "]->(B:" + objCategory.getLabel() + "{ Name : {CategoryName} })") .OnCreate() .Set("B = { objCategory }") .OnMatch() .Set("B = {objCategory }") .WithParams(new { Name = objRoot.Name, objCategory = objCategory, objRoot = objRoot, CategoryName = objCategory.Name }) .Return((B, R) => new { CategoryCount = B.Count(), RelationCount = R.Count() }) .Results .Single(); if (result.CategoryCount == 1) { Logger.WriteToLogFile("Successfully created category"); } else { Logger.WriteToLogFile("Unable to create category"); } }