Exemplo n.º 1
0
        private static ICypherFluentQuery CommonCreate <T>(
            this ICypherFluentQuery query
            , T entity
            , CreateOptions options
            , Func <string, string> getFinalCql) where T : class
        {
            if (options == null)
            {
                options = new CreateOptions();
            }

            var createProperties      = GetCreateProperties(entity);
            var identifier            = entity.EntityParamKey(options.Identifier);
            var intermediateCreateCql = GetMatchWithParam(identifier, entity.EntityLabel(), createProperties.Count > 0 ? identifier : "");

            var createCql = getFinalCql(intermediateCreateCql);

            var dynamicOptions = new CreateDynamicOptions {
                IgnoreNulls = true
            };                                                                    // working around some buug where null properties are blowing up. don't care on create.
            var cutdownEntity = entity.CreateDynamic(createProperties, dynamicOptions);

            query = query.Create(createCql);

            if (createProperties.Count > 0)
            {
                query = query.WithParam(identifier, cutdownEntity);
            }

            return(query);
        }
        public ICypherFluentQuery Create(ICypherFluentQuery fluentQuery, bool merge = false)
        
        {

            fluentQuery.Create(NodeWithAlias());//.ExecuteWithoutResults();
            return fluentQuery;
        }
        public void Execute(ICypherFluentQuery cypher)
        {

            ProcessStacks();

            foreach (var query in _queryStack)
            {

                if (query.QueryType == QueryTypeEnum.Match)
                {
                    cypher = cypher.Match(query.QueryString);
                    continue;
                }
                if (query.QueryType == QueryTypeEnum.OptionalMatch)
                {
                    cypher = cypher.OptionalMatch(query.QueryString);
                    continue;
                }

                if (query.QueryType == QueryTypeEnum.Where)
                {
                    cypher = cypher.Where(query.QueryString);
                    continue;
                }

                if (query.QueryType == QueryTypeEnum.Create)
                {
                    cypher = cypher.Create(query.QueryString);
                    continue;
                }

                if (query.QueryType == QueryTypeEnum.Merge)
                {
                    cypher = cypher.Merge(query.QueryString);
                    continue;
                }

                if (query.QueryType == QueryTypeEnum.Delete)
                {
                    cypher = cypher.Delete(query.QueryString);
                    continue;
                }

                if (query.QueryType == QueryTypeEnum.With)
                {
                    cypher = cypher.With(query.QueryString);
                    continue;
                }

            }

            cypher.ExecuteWithoutResults();
        }