Exemplo n.º 1
0
        private static XElement[] GetTableRec(TableStructure table)
        {
            List <XElement> _retval = new List <XElement>();

            //process main table
            XElement _xmltable = new XElement(table.Table,
                                              new XAttribute("name", table.Name),
                                              new XAttribute("alias", table.Alias),
                                              new XAttribute("keys", table.Keys)
                                              );

            //process all rows
            List <XElement> _rows = new List <XElement>();

            foreach (var row in table.Inserts)
            {
                _rows.Add(GetRowRec(row, "INSERT"));
            }
            foreach (var row in table.Updates)
            {
                _rows.Add(GetRowRec(row, "UPDATE"));
            }
            foreach (var row in table.Deletes)
            {
                _rows.Add(GetRowRec(row, "DELETE"));
            }
            _xmltable.Add(_rows);

            //add to list
            _retval.Add(_xmltable);

            //process all child tables
            foreach (var subtable in table.ChildTables)
            {
                //add to list
                _retval.AddRange(GetTableRec(subtable));
            }

            return(_retval.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// allows for easy creation of a rec structure from within the recs structure
        /// </summary>
        /// <param name="table"></param>
        /// <param name="name"></param>
        /// <param name="alias"></param>
        /// <param name="keys"></param>
        /// <param name="inserts">a list of key value parameters for insert rows</param>
        /// <param name="updates">a list of key value parameters for update rows</param>
        /// <param name="deletes">a list of key value parameters for delete rows</param>
        /// <returns></returns>
        public TableStructure AddTable(string table, string name, string alias, string keys,
                                       RowStrucure inserts = null, RowStrucure updates = null, RowStrucure deletes = null)
        {
            TableStructure tbl = new TableStructure()
            {
                Table = table, Name = name, Alias = alias, Keys = keys
            };

            if (inserts != null)
            {
                tbl.Inserts = inserts;
            }
            if (updates != null)
            {
                tbl.Updates = updates;
            }
            if (deletes != null)
            {
                tbl.Deletes = deletes;
            }
            Tables.Add(tbl);

            return(tbl);
        }