public override void RemoveAll(Relationship relationship, OGM item, DateTime?moment, bool timedependent) { Dictionary <string, object?> parameters = new Dictionary <string, object?>(); parameters.Add("key", item.GetKey()); DirectionEnum direction = relationship.ComputeDirection(item.GetEntity()); string match = (direction == DirectionEnum.Out) ? "MATCH (item:{0})<-[r:{1}]-(out)" : "MATCH (item:{0})-[r:{1}]->(out)"; Entity outEntity = (direction == DirectionEnum.Out) ? relationship.InEntity : relationship.OutEntity; string condition = string.Join(" OR ", outEntity.GetDbNames("out")); if (timedependent) { parameters.Add("moment", Conversion <DateTime, long> .Convert(moment ?? DateTime.MinValue)); // End Current string cypher = string.Format( match + " WHERE ({2}) and item.{3} = {{key}} and (r.{5} > {{moment}} OR r.{5} IS NULL) AND (r.{4} <={{moment}} OR r.{4} IS NULL) SET r.EndDate = {{moment}}", item.GetEntity().Label.Name, relationship.Neo4JRelationshipType, condition, item.GetEntity().Key.Name, relationship.StartDate, relationship.EndDate); Transaction.RunningTransaction.Run(cypher, parameters); // Remove Future cypher = string.Format( match + " WHERE ({2}) and item.{3} = {{key}} and r.{4} > {{moment}} DELETE r", item.GetEntity().Label.Name, relationship.Neo4JRelationshipType, condition, item.GetEntity().Key.Name, relationship.StartDate); Transaction.RunningTransaction.Run(cypher, parameters); //IResult result = trans.Run(cypher, parameters); //if (result.Summary.Counters.RelationshipsDeleted == 0) // throw new ApplicationException($"Unable to delete all time dependent future relationships '{relationship.Neo4JRelationshipType}' related to {item.GetEntity().Label.Name}({item.GetKey()})."); } else { string cypher = string.Format( match + " WHERE ({2}) and item.{3} = {{key}} DELETE r", item.GetEntity().Label.Name, relationship.Neo4JRelationshipType, condition, item.GetEntity().Key.Name); Transaction.RunningTransaction.Run(cypher, parameters); //IResult result = trans.Run(cypher, parameters); //if (result.Summary.Counters.RelationshipsDeleted == 0) // throw new ApplicationException($"Unable to remove all relationships '{relationship.Neo4JRelationshipType}' related to {item.GetEntity().Label.Name}({item.GetKey()})."); } }