private void Window_Loaded(object sender, RoutedEventArgs e) { tables = RailwaysDBQueries.GetUserTablesNames(); for (int i = 0; i < tables.Count; ++i) { tables[i] = tables[i].Replace(" ", String.Empty); } if (tables != null) { foreach (string name in tables) { if (name != "USERS" && name != "PERMISSION_TYPE" && name != "sysdiagrams") { ComboBoxItem item = new ComboBoxItem(); item.Content = TypesConverter.GetResource(name); item.Tag = name; TablesComboBox.Items.Add(item); } } } ; }
public static void FillIds() { if (!filled) { List <string> tables = RailwaysDBQueries.GetUserTablesNames(); foreach (string table in tables) { dynamic d = context.GetType().GetProperty(table).GetValue(context, null); int?ans = null; if (context.GetType().GetProperty(table).PropertyType.GetGenericArguments()[0].GetProperty("ID") != null) { ans = 0; } foreach (dynamic q in d) { try { int id = (int)context.GetType().GetProperty(table).PropertyType.GetGenericArguments()[0].GetProperty("ID").GetValue(q, null); if (id > ans) { ans = id; } } catch { } } if (ans != null) { ids.Add(table, (int)ans + 1); } } filled = true; } }