Esempio n. 1
0
        private void LoadTables()
        {
            throw new NotImplementedException("Loading");
            //Model.ExecutionItems.Clear();
            // TODO: Also clear caches
            Model.IsQueryRunning = true;

            TableEntityCollection tables = null;

            Action a = new Action(() =>
            {
                using (var tda = new TableEntityDataAccess(Model.ConnectionString))
                {
                    tables = tda.GetAllTablesAndColumns();
                }

                DispatcherSupplier.CurrentDispatcher.Invoke(
                    DispatcherPriority.Normal,
                    (Action) delegate
                {
                    Model.Tables         = tables;
                    Model.SelectedTable  = Model.Tables.FirstOrDefault();
                    Model.SelectedColumn = Model.SelectedTable.Columns.FirstOrDefault();

                    Model.SetTablesView();

                    //Model.SelectedExecutionItem = Model.ExecutionItems.FirstOrDefault();
                    Model.IsQueryRunning = false;
                });
            });


            a.BeginInvoke(null, null);
        }
Esempio n. 2
0
        public void ShouldRun_GetRoot()
        {
            TableEntityDataAccess tda = new TableEntityDataAccess(Connection());
            var tables = tda.GetAllTablesAndColumns();

            tda.GetTreeStructureFromRoot(new TableEntity("Person", "Person"), tables);
        }
Esempio n. 3
0
        public void ShouldRun_TruncateTable()
        {
            TableEntityDataAccess tda = new TableEntityDataAccess(Connection());
            var table = tda.GetTableAndColumns("Person", "Person");

            tda.TruncateTable(table);
        }
Esempio n. 4
0
        public void ShouldRun_GetPrimaryKeysForColumnInTable()
        {
            TableEntityDataAccess tda = new TableEntityDataAccess(Connection());
            var table = tda.GetTableAndColumns("Person", "Person");

            var pks = tda.GetPrimaryKeysForColumnInTable(table, table.Columns.First().ColumnName);
        }
Esempio n. 5
0
        public void ShouldRun_CloneTables()
        {
            TableEntityDataAccess tda = new TableEntityDataAccess(Connection());
            var tables = tda.GetAllTablesAndColumns();

            var clone = tda.CloneTables(tables);
        }
        private void CreateTreeWithTableAsRoot(TableEntity table)
        {
            using (TableEntityDataAccess tda = new TableEntityDataAccess(Model.ConnectionString))
            {
                IEnumerable <TableEntity> tables = tda.GetTreeStructureFromRoot(table, Model.Tables);

                AddExecutionItem(tables);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Get available foreign keys in the table for the target column
        /// </summary>
        /// <param name="tda">the tableEntityDataAccess to use to fetch the foreign keys from database</param>
        /// <param name="table">the table from wich to get the keys</param>
        /// <param name="primaryKeyColumn">the key column to get keys for</param>
        /// <returns>a ObservableCollection<string> with the keys for the table</returns>
        /// <remarks>keys will be cached for next time they are requested.</remarks>
        public ObservableCollection <string> GetPrimaryKeysForTable(TableEntityDataAccess tda, TableEntity table, string primaryKeyColumn)
        {
            ObservableCollection <string> fkeys;

            ForeignKeyContainer cached = ForeignKeyContainerCache.Where(x => x.Table.FullName == table.FullName).FirstOrDefault();

            if (cached != null)
            {
                fkeys = cached.KeyValues;
            }
            else
            {
                fkeys = tda.GetPrimaryKeysForColumnInTable(table, primaryKeyColumn);
                ForeignKeyContainerCache.Add(new ForeignKeyContainer(table, primaryKeyColumn, fkeys));
            }
            return(fkeys);
        }
 public static ExecutionNode CloneFromTable(TableEntity table, TableEntityDataAccess tda)
 {
     TableEntity clonedTable = tda.CloneTable(table);
     throw new NotImplementedException("CloneFromTable");
     //return new ExecutionNode(clonedTable);
 }
 public static IEnumerable<ExecutionNode> GetExecutionItemsFromTables(IEnumerable<TableEntity> tables, TableEntityDataAccess tda)
 {
     // Clone the selected table so that each generation of that table is configurable uniquely
     foreach (var table in tables)
     {
         yield return CloneFromTable(table, tda);
     }
 }
Esempio n. 10
0
 public void ShouldRun_GetTableAndColumns()
 {
     TableEntityDataAccess tda = new TableEntityDataAccess(Connection());
     var tables = tda.GetTableAndColumns("Person", "Person");
 }