Пример #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
 /// <summary>
 /// Inserts all the elements and all the relationships that are annotated with <c>CascadeOperation.CascadeInsert</c>
 /// into the database. If any element already exists in the database a 'Constraint' exception will be raised.
 /// Elements with a primary key that it's not <c>AutoIncrement</c> will need a valid identifier before calling
 /// this method.
 /// If the <c>recursive</c> flag is set to true, all the relationships annotated with
 /// <c>CascadeOperation.CascadeInsert</c> are inserted recursively in the database. This method will handle
 /// loops and inverse relationships correctly. <c>ReadOnly</c> properties will be omitted.
 /// </summary>
 /// <param name="conn">SQLite Net connection object</param>
 /// <param name="elements">Objects to be inserted.</param>
 /// <param name="recursive">If set to <c>true</c> all the insert-cascade properties will be inserted</param>
 public static void InsertAllWithChildren(this SQLiteConnection conn, IEnumerable elements, bool recursive = false)
 {
     conn.InsertAllWithChildrenRecursive(elements, false, recursive);
 }