Exemplo n.º 1
0
        public static TypeWrappedCypherFluentQuery <U, U> Build <U>(Func <IDriver> client) //where U : class, INeo4jNode, new()
        {
            TypeWrappedCypherFluentQuery <U, U> ths = new TypeWrappedCypherFluentQuery <U, U>(client);

            ths.rQ = ths;
            //ths.quearyExpression = x => x;
            return(ths);
        }
Exemplo n.º 2
0
        public TypeWrappedCypherFluentQuery <T, V> ThenIncludeCollection <U, V>(Expression <Func <S, IEnumerable <U> > > p, Expression <Func <U, V> > q)
        //where A : IEnumerable<U>
        //where U : class, INeo4jNode, new()
        //where V : class, INeo4jNode, new()
        {
            TypeWrappedCypherFluentQuery <T, IEnumerable <U> > s1 = (TypeWrappedCypherFluentQuery <T, IEnumerable <U> >) this.ThenInclude(p);
            TypeWrappedCypherFluentQuery <T, U> s2 = s1.SubBuild <U>(s1.quearyName);
            TypeWrappedCypherFluentQuery <T, V> s3 = (TypeWrappedCypherFluentQuery <T, V>)s2.ThenInclude(q);

            return(s3);
        }
Exemplo n.º 3
0
        private TypeWrappedCypherFluentQuery <T, S> BackCopy <U>(TypeWrappedCypherFluentQuery <T, U> typeWrappedCypherFluentQuery)
        {
            TypeWrappedCypherFluentQuery <T, S> bccp = this;

            bccp.internalQ        = typeWrappedCypherFluentQuery.internalQ;
            bccp.pulledChildNodes = bccp.pulledChildNodes.Union(
                typeWrappedCypherFluentQuery.pulledChildNodes
                ).Distinct().ToList();
            bccp.pulledPaths = bccp.pulledPaths.Union(
                typeWrappedCypherFluentQuery.pulledPaths
                ).Distinct().ToList();
            bccp.PathCount = typeWrappedCypherFluentQuery.PathCount;
            if (bccp is TypeWrappedCypherFluentQuery <T, T> )
            {
                var v = (bccp as TypeWrappedCypherFluentQuery <T, T>);
                //v.quearyExpression = x => x;
                bccp = v as TypeWrappedCypherFluentQuery <T, S>;
            }
            return(bccp);
        }
Exemplo n.º 4
0
        public TypeWrappedCypherFluentQuery <T, U> ThenInclude <U>(Expression <Func <S, U> > p) //where U : class, INeo4jNode, new()
        {
            p = Scrub(p);

            List <(string, ReflectionCache.Property, MemberExpression)> fullPath = new List <(string, ReflectionCache.Property, MemberExpression)>();

            Expression bdy = p.Body;
            TypeWrappedCypherFluentQuery <T, S> ths = this;

            while (bdy is MemberExpression)
            {
                MemberExpression         mExp     = bdy as MemberExpression;
                PropertyInfo             propInfo = mExp.Member as PropertyInfo;
                ReflectionCache.Property prop     = new ReflectionCache.Property(propInfo);

                fullPath.Add((mExp.ToString().Replace('.', '_'), prop, mExp));

                bdy = mExp.Expression;
            }

            fullPath.Reverse();

            foreach (var v in fullPath)
            {
                string[] strPath    = v.Item1.Split("_");
                string   parentName = strPath.Take(strPath.Length - 1).Aggregate((a, b) => a + "_" + b);

                if (!pulledPaths.Contains(v.Item1))
                {
                    internalQ = internalQ.AppendLine($"OPTIONAL MATCH p{PathCount} = ({parentName})-[:{v.Item2.neo4JAttributes.Select(x => x as DbNameAttribute).Where(x => x != null).FirstOrDefault()?.Name ?? v.Item2.info.Name}]->({v.Item1})");
                    pulledPaths.Add(v.Item1);
                    PathCount++;
                }
            }

            string ultimateChild = fullPath.Any() ? fullPath.Last().Item1 : "";

            return(SubBuild <U>(ultimateChild));
        }
Exemplo n.º 5
0
 public static TypeWrappedCypherFluentQuery <T, T> All(Func <IDriver> client)
 {
     return(TypeWrappedCypherFluentQuery <T, T> .Build <T>(client));
 }