private void RestoreDatabase(int tenant, ConnectionStringSettings connectionString, IEnumerable<XElement> elements, IDataReadOperator reader) { var dbName = connectionString.Name; var dbElement = elements.SingleOrDefault(e => string.Compare(e.Name.LocalName, connectionString.Name, true) == 0); if (dbElement != null && dbElement.Attribute("ref") != null) { dbName = dbElement.Attribute("ref").Value; dbElement = elements.Single(e => string.Compare(e.Name.LocalName, dbElement.Attribute("ref").Value, true) == 0); } if (dbElement == null) return; using (var dbHelper = new DbHelper(tenant, connectionString)) { var tables = dbHelper.GetTables(); for (int i = 0; i < tables.Count; i++) { var table = tables[i]; OnProgressChanged(table, (int)(i / (double)tables.Count * 100)); if (dbElement.Element(table) == null) continue; var stream = reader.GetEntry(string.Format("{0}\\{1}\\{2}", Name, dbName, table).ToLower()); var data = new DataTable(); data.ReadXml(stream); dbHelper.SetTable(data); } } }