コード例 #1
0
        /// <summary>
        /// Used to merge CONSTRAINT xxx / NEXT constraint pairs (they are actually the
        /// same constraint).
        /// </summary>
        /// <param name="cons">The list to merge</param>
        /// <returns>The resulting (merged) constraints list</returns>
        public static List <SQLiteTableConstraint> Merge(List <SQLiteTableConstraint> cons)
        {
            List <SQLiteTableConstraint> res = new List <SQLiteTableConstraint>();

            for (int i = 0; i < cons.Count; i++)
            {
                SQLiteTableConstraint c = cons[i];
                if (c.GetType() == typeof(SQLiteTableConstraint) && c.ConstraintName != null)
                {
                    i++;
                    if (i < cons.Count)
                    {
                        SQLiteTableConstraint next = cons[i];
                        next.ConstraintName = c.ConstraintName;
                        res.Add(next);
                    }
                }
                else
                {
                    res.Add(c);
                }
            } // for

            return(res);
        }