Example #1
0
        private void FromDBButton_Click(object sender, RoutedEventArgs e)
        {
            var data = new List <GenTextManagerViewModel.TextData>();

            var skippedTables = new List <string>(
                vm.SkippedTable.Split(new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries));
            var skippedColumns = new List <string>(
                vm.SkippedColumn.Split(new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries));

            foreach (var table in DatabaseUtils.ListTables(vm.DatabaseName))
            {
                if (skippedTables.Count > 0 && skippedTables.Contains(table))
                {
                    continue;
                }

                var properties = DatabaseUtils.ListColumnsOfTable(vm.DatabaseName, table);
                foreach (var prop in properties)
                {
                    if (skippedColumns.Count > 0 && skippedColumns.Contains(prop.PropertyName))
                    {
                        continue;
                    }

                    data.Add(new GenTextManagerViewModel.TextData()
                    {
                        TextKey   = string.Format("{0}_{1}", table, prop.PropertyName),
                        TextValue = prop.PropertyName
                    });
                }
            }

            vm.Result = CodeGenerator.GenTextManagerClass(vm.Namespace, data);
        }
Example #2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var skippedTable = new List <string>(
                vm.SkippedTable.Split(new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries));

            foreach (var table in DatabaseUtils.ListTables(vm.DatabaseName))
            {
                if (skippedTable.Count > 0 && skippedTable.Contains(table))
                {
                    continue;
                }

                var properties = DatabaseUtils.ListColumnsOfTable(vm.DatabaseName, table);
                var dtoClass   = CodeGenerator.GenViewModelClass(vm.Namespace, table, properties);
                var path       = vm.OutputPath + "\\" + table + "ViewModel.cs";
                FileUtils.WriteAllTextInUTF8(path, dtoClass);
            }
        }