public void Insert(T entity) { var query = _context.GraphDb.Cypher .Create(CypherQueries.CypherNodeMapWithParam <T>("x", "y")) .WithParam("y", entity); query.ExecuteWithoutResults(); }
private ICypherFluentQuery BaseRelationshipMap(T entity, TLeft originNode, TRight destinyNode, string relVarName) { var o = CypherQueries.CypherNodeMap <TLeft>("from"); var d = CypherQueries.CypherNodeMap <TRight>("to"); string inputString = string.Format("{0}-[{2}: {3}]->{1}", o, d, relVarName, typeof(T).Name); return(_context.GraphDb.Cypher .Match(inputString) .Where((TLeft from) => from.Id == originNode.Id) .AndWhere((TRight to) => to.Id == destinyNode.Id)); }
public void Delete(int id) { var query = _context.GraphDb.Cypher .OptionalMatch(string.Format("{0}-[{1}]-()", CypherNodeMap("x"), "r")) .Where(CypherQueries.CypherWhereClauseWithIntParam("x", "Id", id)) .Delete("r, x"); query.ExecuteWithoutResults(); //if no relationships exists //BaseQueryFilteredById("x", id).Delete("x").ExecuteWithoutResults(); }
public void Insert(T entity, TLeft originNode, TRight destinyNode) { var origin = CypherQueries.CypherNodeMap <TLeft>("from"); var destiny = CypherQueries.CypherNodeMap <TRight>("to"); _context.GraphDb.Cypher .Match(origin, destiny) .Where((TLeft from) => from.Id == originNode.Id) .AndWhere((TRight to) => to.Id == destinyNode.Id) .CreateUnique(string.Format("(from)-[:{0} {{{1}}}]->(to)", typeof(T).Name, "params")) .WithParam("params", entity) .ExecuteWithoutResults(); }
public IEnumerable <T> GetById(int originId, int destinyId) { var o = CypherQueries.CypherNodeMap <TLeft>("from"); var d = CypherQueries.CypherNodeMap <TRight>("to"); string inputString = string.Format("{0}-[{2}: {3}]->{1}", o, d, "r", typeof(T).Name); var query = _context.GraphDb.Cypher .Match(inputString) .Where((TLeft from) => from.Id == originId) .AndWhere((TRight to) => to.Id == destinyId) .Return <T>("r"); return(query.Results); }
private ICypherFluentQuery BaseQueryFilteredById(string varName, int id) { return(BaseQuery(varName). Where(CypherQueries.CypherWhereClauseWithIntParam(varName, "Id", id))); }