public void ImportData(object sender, ExecutedRoutedEventArgs e)
        {
            var menuInfo = ValidateMenuInfo(sender);
            if (menuInfo != null)
            {
                try
                {
                    using (IRepository repository = RepoHelper.CreateRepository(menuInfo.Connectionstring))
                    {
                        var generator = RepoHelper.CreateGenerator(repository, string.Empty);

                        ImportDialog imo = new ImportDialog();

                        imo.SampleHeader = generator.GenerateTableColumns(menuInfo.Name);
                        imo.Separator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToCharArray()[0];
                        imo.Owner = Application.Current.MainWindow;
                        if (imo.ShowDialog() == true)
                        {
                            using (var reader = new CsvReader(imo.File, System.Text.Encoding.UTF8))
                            {
                                reader.ValueSeparator = imo.Separator;
                                HeaderRecord hr = reader.ReadHeaderRecord();
                                if (generator.ValidColumns(menuInfo.Name, hr.Values))
                                {
                                    int i = 1;
                                    foreach (DataRecord record in reader.DataRecords)
                                    {
                                        generator.GenerateTableInsert(menuInfo.Name, hr.Values, record.Values, i);
                                        i++;
                                    }
                                }
                            }
                            OpenSqlEditorToolWindow(menuInfo, generator.GeneratedScript);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex));
                }
            }
        }
        public void ImportData(object sender, ExecutedRoutedEventArgs e)
        {
            var menuInfo = ValidateMenuInfo(sender);
            if (menuInfo == null) return;
            try
            {
                using (IRepository repository = Helpers.DataConnectionHelper.CreateRepository(menuInfo.DatabaseInfo))
                {
                    var generator = Helpers.DataConnectionHelper.CreateGenerator(repository, menuInfo.DatabaseInfo.DatabaseType);

                    ImportDialog imo = new ImportDialog();

                    imo.SampleHeader = generator.GenerateTableColumns(menuInfo.Name);
                    imo.Separator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToCharArray()[0];

                    if (imo.ShowModal() == true)
                    {
                        if (!string.IsNullOrWhiteSpace(imo.File) && System.IO.File.Exists(imo.File))
                        {
                            using (var reader = new CsvReader(imo.File, System.Text.Encoding.UTF8))
                            {
                                reader.ValueSeparator = imo.Separator;
                                HeaderRecord hr = reader.ReadHeaderRecord();
                                if (generator.ValidColumns(menuInfo.Name, hr.Values))
                                {
                                    int i = 1;
                                    foreach (DataRecord record in reader.DataRecords)
                                    {
                                        generator.GenerateTableInsert(menuInfo.Name, hr.Values, record.Values, i);
                                        i++;
                                    }
                                }
                            }
                            OpenSqlEditorToolWindow(menuInfo, generator.GeneratedScript);
                            Helpers.DataConnectionHelper.LogUsage("TableImport");
                        }
                    }
                }
            }
            catch (System.IO.IOException iox)
            {
                EnvDTEHelper.ShowError(iox.Message);
            }
            catch (Exception ex)
            {
                Helpers.DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType, false);
            }
        }