Beispiel #1
0
        public string ParamsTostring(Dictionary <string, object> parameters, bool IsUpdate)
        {
            var setCaluseOnCreate = new Lazy <StringBuilder>();

            foreach (var item in parameters)
            {
                if (item.Key == "Uuid" && IsUpdate)
                {
                    continue;
                }
                if (item.Value is string)
                {
                    var strok = EscapeSymbols.ConvertToCypher(item.Value as string);
                    setCaluseOnCreate.Value.Append((item.Value != null) ? $@"n.{item.Key} = ""{strok}"", " : "");
                    continue;
                }
                if (item.Value is IEnumerable <object> )
                {
                    CollectionToQuery(setCaluseOnCreate, item);
                    continue;
                }
            }
            var str = setCaluseOnCreate.Value.ToString().TrimEnd(' ').TrimEnd(',');

            return(str);
        }
Beispiel #2
0
        private void CollectionToQuery(Lazy <StringBuilder> stringBuilder, KeyValuePair <string, object> item)
        {
            var collection = (item.Value as IEnumerable <object>).ToList();

            if (collection.Count != 0)
            {
                stringBuilder.Value.Append((item.Value != null) ? $@"n.{item.Key} = ""[" : "");
                for (var i = 0; i < collection.Count; i++)
                {
                    var strok = EscapeSymbols.ConvertToCypher(collection[i] as string);
                    stringBuilder.Value.Append($@"{strok}, ");
                }
                stringBuilder.Value.Remove(stringBuilder.Value.Length - 2, 2);
                stringBuilder.Value.Append(@"]"", ");
            }
        }