Ejemplo n.º 1
0
        public static VimSchema Create(Document doc)
        {
            var r = new VimSchema();

            r.Version = doc.Header.ObjectModelVersion.ToString();
            foreach (var et in doc.EntityTables.Values.ToEnumerable())
            {
                var t = new Table()
                {
                    Name = et.Name.SimplifiedName()
                };

                r.Tables.Add(t);

                foreach (var c in et.IndexColumns.Values.ToEnumerable())
                {
                    t.AddColumn(c.Name, ColumnType.Index);
                }

                foreach (var c in et.NumericColumns.Values.ToEnumerable())
                {
                    t.AddColumn(c.Name, ColumnType.Numeric);
                }

                foreach (var c in et.StringColumns.Values.ToEnumerable())
                {
                    t.AddColumn(c.Name, ColumnType.String);
                }
            }
            return(r);
        }
Ejemplo n.º 2
0
        public VimSchema AddedOrChanged(VimSchema previous, bool changedOnly)
        {
            var r = new VimSchema();

            r.Version = $"{previous.Version} => {Version}";
            foreach (var t in Tables)
            {
                var previousTable = previous.FindTable(t.Name);
                if (previousTable == null && !changedOnly)
                {
                    r.Tables.Add(t);
                }
                else if (previousTable != null)
                {
                    var newTable = new Table()
                    {
                        Name = t.Name
                    };
                    foreach (var c in t.Columns)
                    {
                        var previousColumn = previousTable.FindColumn(c.Name);
                        if (previousColumn == null && !changedOnly)
                        {
                            newTable.Columns.Add(c);
                        }
                        if (previousColumn != null && changedOnly && c.Type != previousColumn.Type)
                        {
                            newTable.Columns.Add(c);
                        }
                    }
                    // If there are any new columns
                    if (newTable.Columns.Count > 0)
                    {
                        r.Tables.Add(newTable);
                    }
                }
            }
            return(r);
        }
Ejemplo n.º 3
0
 public static bool SameSchema(VimSchema vim1, VimSchema vim2)
 => vim1.IsSame(vim2);
Ejemplo n.º 4
0
 public bool IsSame(VimSchema vs)
 => Added(vs).Tables.Count == 0 &&
 Removed(vs).Tables.Count == 0 &&
 Modified(vs).Tables.Count == 0;
Ejemplo n.º 5
0
 public VimSchema Modified(VimSchema previous)
 => AddedOrChanged(previous, true);
Ejemplo n.º 6
0
 public VimSchema Removed(VimSchema previous)
 => previous.Added(this);
Ejemplo n.º 7
0
 public VimSchema Added(VimSchema previous)
 => AddedOrChanged(previous, false);