コード例 #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 or replace the element and all the relationships that are annotated with
 /// <c>CascadeOperation.CascadeInsert</c> into the database. If any element already exists in the database
 /// it will be replaced. Elements with <c>AutoIncrement</c> primary keys that haven't been assigned will
 /// be always inserted instead of replaced.
 /// 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="element">Object 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 InsertOrReplaceWithChildren(this SQLiteConnection conn, object element, bool recursive = false)
 {
     conn.InsertWithChildrenRecursive(element, true, recursive);
 }