Esempio n. 1
0
 public static async Task <List <TResult> > ToListAsync <TResult>(this ICypherFluentQuery query, Expression <Func <ICypherResultItem, TResult> > expression, string orderBy = null, int?skip = null, int?limit = null)
 {
     if (orderBy.HasValue())
     {
         var returnExp = query.Return(expression).OrderBy(orderBy);
         if (skip.HasValue && limit.HasValue)
         {
             var test = returnExp.Skip(skip.Value).Limit(limit.Value);
             return((await test.ResultsAsync).ToList());
         }
         return((await returnExp.ResultsAsync).ToList());
     }
     return((await query.Return(expression).ResultsAsync).ToList());
 }
        private RelationshipCheckResponse Check(ICypherFluentQuery q, IRelationshipCheckRequest request)
        {
            q = q.With("ID(e) as nodeId, count(rel) as relationshipCount");

            switch (request.ThresholdType)
            {
                case RelationshipThresholdType.ReturnIfGreaterThan:
                    q = q.Where($"relationshipCount > {request.Threshold}");
                    break;

                case RelationshipThresholdType.ReturnIfNotExact:
                    q = q.Where($"relationshipCount <> {request.Threshold}");
                    break;
                case RelationshipThresholdType.ReturnIfEqual:
                    q = q.Where($"relationshipCount = {request.Threshold}");
                    break;

                default:
                    throw new Exception("<INSERT PR HERE>");
            }

            var responses = q.Return((nodeId, relationshipCount) =>
            new Violation
            {
                NodeId = nodeId.As<long>()
            });

            var response = new RelationshipCheckResponse();
            response.Request = request;
            response.Violations.AddRange(responses.Results.ToList());
            return response;
        }
Esempio n. 3
0
        /// <summary>
        ///     Erstellt einen neuen Logeintrag einer Variation
        /// </summary>
        public LogEntry Create(Variation variation, LogEntry logEntry)
        {
            ICypherFluentQuery query = GraphClient.Cypher
                                       .Match("".Variation("v"))
                                       .Where((Variation v) => v.Id == variation.Id)
                                       .Create("".Node("v").Has().LogEntryWithParam())
                                       .WithParam("logEntry", logEntry);

            return(query.Return(le => le.As <LogEntry>()).Results.First());
        }
Esempio n. 4
0
        /// <summary>
        ///     Erstellt einen neuen Schwierigkeitsgrad in einer Skala
        /// </summary>
        public DifficultyLevel Create(DifficultyLevelScale difficultyLevelScale, DifficultyLevel difficultyLevel)
        {
            ICypherFluentQuery query = GraphClient.Cypher
                                       .Match("".DifficultyLevelScale("dls"))
                                       .Where((DifficultyLevelScale dls) => dls.Id == difficultyLevelScale.Id)
                                       .Create("dls".Has().DifficultyLevelWithParam())
                                       .WithParam("difficultyLevel", difficultyLevel);

            return(query.Return(dl => dl.As <DifficultyLevel>()).Results.First());
        }
Esempio n. 5
0
        /// <summary>
        ///     Erstellt eine neue Gipfelgruppe in einer Gegend
        /// </summary>
        /// <param name="area"></param>
        /// <param name="summitGroup"></param>
        public SummitGroup Create(Area area, SummitGroup summitGroup)
        {
            ICypherFluentQuery query = GraphClient.Cypher
                                       .Match("".Area("a"))
                                       .Where((Area a) => a.Id == area.Id)
                                       .Create("a".Has().SummitGroupWithParam())
                                       .WithParam("summitGroup", summitGroup);

            return(query.Return(sg => sg.As <SummitGroup>()).Results.First());
        }
 private ICypherFluentQuery <RouteResponse> ReturnRouteResponse(ICypherFluentQuery query)
 {
     return(query.Return(() => new RouteResponse
     {
         Origin = Return.As <Warehouse>("from"),
         Destiny = Return.As <Warehouse>("to"),
         RoutePoints = Return.As <IEnumerable <Warehouse> >("[x IN nodes(path) WHERE (x:Warehouse) | x]"),
         ShipDetails = Return.As <IEnumerable <SHIPS_TO> >("[y IN relationships(path) | y]"),
         Hops = Return.As <int>("length(path)"),
         TotalCost = Return.As <int>("reduce(accumCost = 0, r IN relationships(path)| accumCost + r.cost)"),
         TotalTime = Return.As <int>("reduce(accumTime = 0, r IN relationships(path)| accumTime + r.time)")
     }));
 }
    public ICollection <T> Find <T>(Expression <Func <T, bool> > filter) where T : IEntity
    {
        ICypherFluentQuery queryWithoutReturn = _graphClient.Cypher
                                                .Match(String.Format("(n:{0})", typeof(T).Name));

        if (filter != null)
        {
            queryWithoutReturn = queryWithoutReturn.Where(filter);
        }

        var query = queryWithoutReturn.Return(n => n.As <T>());

        QueryDebugText(MethodBase.GetCurrentMethod().Name, query);

        return(query.ResultsAsync.Result.ToList());
    }
Esempio n. 8
0
 public static TResult FirstOrDefault <TResult>(this ICypherFluentQuery query, Expression <Func <TResult> > expression)
 {
     return(query.Return(expression).FirstOrDefault());
 }
Esempio n. 9
0
 public static async Task <TResult> FirstOrDefaultAsync <TResult>(this ICypherFluentQuery query, Expression <Func <TResult> > expression)
 {
     return(await query.Return(expression).FirstOrDefaultAsync());
 }
Esempio n. 10
0
        public static async Task <TResult> FirstOrDefaultAsync <TResult>(this ICypherFluentQuery query, Expression <Func <ICypherResultItem, TResult> > expression)
        {
            var returnExp = query.Return(expression);

            return(await returnExp.FirstOrDefaultAsync());
        }