예제 #1
0
        static void InsertValue(this SQLiteConnection conn, object value, bool replace, bool recursive, ISet <object> objectCache)
        {
            if (value == null)
            {
                return;
            }

            var enumerable = value as IEnumerable;

            if (recursive)
            {
                if (enumerable != null)
                {
                    conn.InsertAllWithChildrenRecursive(enumerable, replace, recursive, objectCache);
                }
                else
                {
                    conn.InsertWithChildrenRecursive(value, replace, recursive, objectCache);
                }
            }
            else
            {
                if (enumerable != null)
                {
                    conn.InsertElements(enumerable, replace, objectCache);
                }
                else
                {
                    conn.InsertElement(value, replace, objectCache);
                }
            }
        }
예제 #2
0
        static void InsertAllWithChildrenRecursive(this SQLiteConnection conn, IEnumerable elements, bool replace, bool recursive, ISet <object> objectCache = null)
        {
            if (elements == null)
            {
                return;
            }

            objectCache = objectCache ?? new HashSet <object>();
            var insertedElements = conn.InsertElements(elements, replace, objectCache).Cast <object>().ToList();

            foreach (var element in insertedElements)
            {
                conn.InsertChildrenRecursive(element, replace, recursive, objectCache);
            }

            foreach (var element in insertedElements)
            {
                conn.UpdateWithChildren(element);
            }
        }