public MainWindow() { this.WindowStartupLocation = WindowStartupLocation.CenterScreen; InitializeComponent(); BtnRemove.IsEnabled = false; BtnEdit.IsEnabled = false; BtnOpenClub.IsEnabled = false; //DataGridFilteredItems.ItemsSource = LoadCollectionData(); #region InicializationDB DataGridFilteredItems.ItemsSource = null; List <Player> toDisplay = DbContext.GetPlayers().ToList(); DataGridFilteredItems.ItemsSource = toDisplay; NumberOfItems = toDisplay.Count; Console.WriteLine("DB Loaded!"); #endregion }
static void Main(string[] args) { var clubFlag = false; var playersFlag = false; var clearDatabase = false; var clubsPath = ""; var playersPath = ""; CheckArgs(args, ref clubFlag, ref playersFlag, ref clubsPath, ref playersPath, ref clearDatabase); var clubs = new List <Club>(); var players = new List <Player>(); if (clubFlag && !string.IsNullOrWhiteSpace(clubsPath)) { ReadClubs(ref clubs, clubsPath); } if (playersFlag && !string.IsNullOrWhiteSpace(playersPath)) { ReadPlayers(ref players, playersPath, ref clubs); } #region InicializationDB using (var db_context = new HockeyContext()) { if (clearDatabase) { db_context.Database.ExecuteSqlCommand("DELETE FROM Player"); db_context.Database.ExecuteSqlCommand("DELETE FROM Club"); } foreach (var club in clubs) { db_context.Clubs.Add(club); } foreach (var player in players) { db_context.Players.Add(player); } db_context.SaveChanges(); foreach (var club in db_context.GetClubs()) { Console.WriteLine(club); } foreach (var player in db_context.GetPlayers()) { Console.WriteLine(player); } } Console.WriteLine("DB Loaded!"); Console.ReadLine(); #endregion }
private void SetFilteredItemsAll() { TextBlockFilteredItemsAll.Text = _dbContext.GetPlayers().ToList().Count.ToString(); }