Ejemplo n.º 1
0
        static void InsertChildrenRecursive(this SQLiteConnection conn, object element, bool replace, bool recursive, ISet <object> objectCache = null)
        {
            if (element == null)
            {
                return;
            }

            objectCache = objectCache ?? new HashSet <object>();
            foreach (var relationshipProperty in element.GetType().GetRelationshipProperties())
            {
                var relationshipAttribute = relationshipProperty.GetAttribute <RelationshipAttribute>();

                // Ignore read-only attributes and process only 'CascadeInsert' attributes
                if (relationshipAttribute.ReadOnly || !relationshipAttribute.IsCascadeInsert)
                {
                    continue;
                }

                var value = relationshipProperty.GetValue(element, null);
                conn.InsertValue(value, replace, recursive, objectCache);
            }
        }