Esempio n. 1
0
        public static ICypherFluentQuery MergeEntity <T>(this ICypherFluentQuery query, T entity, string paramKey = null, List <CypherProperty> mergeOverride = null, List <CypherProperty> onMatchOverride = null, List <CypherProperty> onCreateOverride = null, string preCql = "", string postCql = "") where T : class
        {
            paramKey = entity.EntityParamKey(paramKey);
            var context = CypherExtensionContext.Create(query);
            var cypher1 = entity.ToCypherString <T, CypherMergeAttribute>(context, paramKey, mergeOverride);
            var cql     = string.Format("{0}({1}){2}", preCql, cypher1, postCql);

            return(query.CommonMerge(entity, paramKey, cql, mergeOverride, onMatchOverride, onCreateOverride));
        }
Esempio n. 2
0
        public static ICypherFluentQuery MergeRelationship <T>(this ICypherFluentQuery query, T entity, List <CypherProperty> mergeOverride = null, List <CypherProperty> onMatchOverride = null, List <CypherProperty> onCreateOverride = null) where T : BaseRelationship
        {
            //Eaxctly the same as a merge entity except the cql is different
            var cql = GetRelationshipCql(
                entity.FromKey
                , entity.ToCypherString <T, CypherMergeAttribute>(CypherExtensionContext.Create(query), entity.Key, mergeOverride)
                , entity.ToKey);

            return(query.CommonMerge(entity, entity.Key, cql, mergeOverride, onMatchOverride, onCreateOverride));
        }
Esempio n. 3
0
        public static ICypherFluentQuery MergeEntity <T>(this ICypherFluentQuery query, T entity, MergeOptions options) where T : class
        {
            var    context = CypherExtensionContext.Create(query);
            string pattern;

            if (options.MergeViaRelationship != null)
            {
                var relationshipSegment = GetAliasLabelCql(string.Empty, options.MergeViaRelationship.EntityLabel());

                pattern = GetRelationshipCql(
                    options.MergeViaRelationship.FromKey
                    , relationshipSegment
                    , GetAliasLabelCql(options.MergeViaRelationship.ToKey, entity.EntityLabel()));
            }
            else
            {
                pattern = entity.ToCypherString <T, CypherMergeAttribute>(context, options.Identifier, options.MergeOverride);
            }
            var wrappedPattern = string.Format("{0}({1}){2}", options.PreCql, pattern, options.PostCql);

            return(query.CommonMerge(entity, options.Identifier, wrappedPattern, options.MergeOverride, options.OnMatchOverride, options.OnCreateOverride));
        }