Esempio n. 1
0
        public void CopyFrom(MTable t)
        {
            Table_catalog = t.Table_catalog;
            Table_schema  = t.Table_schema;
            Table_name    = t.Table_name;
            Table_type    = t.Table_type;

            ColumnList.Clear();
            FkList.Clear();
            IdxList.Clear();

            ColumnList.AddRange(t.ColumnList.Select(c => new MColumn(c)));

            FkList.AddRange(t.FkList.Select(c => new MForeignKey(c)));

            IdxList.AddRange(t.IdxList.Select(c => new MIndex(c)));

            if (t.Tag is ICloneable tag)
            {
                Tag = tag.Clone();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Filter by table, with output funcfion (for debug info)
        /// </summary>
        /// <param name="db"></param>
        /// <param name="arg">'+' - include table, '-' - exclude table</param>
        /// <param name="tableArray">array of tables 'schema.table' ('app.AppUser')</param>
        /// <returns></returns>
        public static DbMsSqlMetadata FilterByTable(this DbMsSqlMetadata db, string arg, Action <string> outputWriteFunc, params string[] tableArray)
        {
            if (string.Equals(arg, "+"))
            {
                for (int i = 0; i < db.TableList.Count; i++)
                {
                    MTable t = db.TableList[i];

                    var tName = $"{t.Table_schema}.{t.Table_name}";

                    if (!tableArray.Contains(tName))
                    {
                        // debuf info
                        outputWriteFunc?.Invoke($"// - remove table {tName}");
                        db.TableList.RemoveAt(i);
                        i--;
                    }
                } // for
            }

            if (string.Equals(arg, "-"))
            {
                for (int i = 0; i < db.TableList.Count; i++)
                {
                    MTable t = db.TableList[i];

                    var tName = $"{t.Table_schema}.{t.Table_name}";

                    if (tableArray.Contains(tName))
                    {
                        db.TableList.RemoveAt(i);
                        i--;
                    }
                } // for
            }

            return(db);
        }
Esempio n. 3
0
        /// <summary>
        /// Filter by table
        /// </summary>
        /// <param name="db"></param>
        /// <param name="arg">'+' - include table, '-' - exclude table</param>
        /// <param name="tableArray">array of tables 'schema.table' ('app.AppUser')</param>
        /// <returns></returns>
        public static DbMsSqlMetadata FilterByTable(this DbMsSqlMetadata db, string arg, params string[] tableArray)
        {
            if (string.Equals(arg, "+"))
            {
                for (int i = 0; i < db.TableList.Count; i++)
                {
                    MTable t = db.TableList[i];

                    var tName = $"{t.Table_schema}.{t.Table_name}";

                    if (!tableArray.Contains(tName))
                    {
                        db.TableList.RemoveAt(i);
                        i--;
                    }
                } // for
            }

            if (string.Equals(arg, "-"))
            {
                for (int i = 0; i < db.TableList.Count; i++)
                {
                    MTable t = db.TableList[i];

                    var tName = $"{t.Table_schema}.{t.Table_name}";

                    if (tableArray.Contains(tName))
                    {
                        db.TableList.RemoveAt(i);
                        i--;
                    }
                } // for
            }

            return(db);
        }
Esempio n. 4
0
 public MTable(MTable source)
 {
     CopyFrom(source);
 }