示例#1
0
        private IDictionary <string, string> LoadInternal(DoltRunner runner, string table, out string parent)
        {
            var ret = runner.Export <KeyValueRow>(table, new KeyValueRowMap(this.Source.KeyField, this.Source.ValueField)).ToDictionary(r => r.Key, r => r.Value);

            ret.TryGetValue(this.Source.ParentKey, out parent);
            return(ret);
        }
示例#2
0
        public override void Load()
        {
            var tempFolder = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "dolt_" + Guid.NewGuid()));

            try
            {
                tempFolder.Create();

                var runner = new DoltRunner(tempFolder.FullName).Clone(this.Source.Url, this.Source.Branch);
                var tables = runner.ListTables().Select(t => t.Name).ToList();
                var table  = GetExistingTable(tables);

                Data = LoadInternal(runner, table, out var parent);

                while (!String.IsNullOrEmpty(parent))
                {
                    foreach (var pair in LoadInternal(runner, parent, out parent))
                    {
                        if (!Data.ContainsKey(pair.Key))
                        {
                            Data.Add(pair);
                        }
                    }
                }
            }
            finally
            {
                Task.Run(() => {
                    RunWithRetry(() =>
                    {
                        if (tempFolder.Exists)
                        {
                            tempFolder.Delete(recursive: true);
                        }
                    }, 700);
                });
            }
        }