public bool TryGetValue(Tuple <string, Region, Sport> key, out League value) { LeagueDictionaryElement element = context.LeagueDictionaryElements.Where((el) => el.Name == key.Item1 && el.SportID == key.Item3.ID && el.RegionID == key.Item2.ID).FirstOrDefault(); value = element?.League; if (element == null) { return(false); } return(true); }
public void Add(Tuple <string, Region, Sport> key, League value) { LeagueDictionaryElement newElement = new LeagueDictionaryElement(); newElement.Name = key.Item1; newElement.SportID = key.Item3.ID; newElement.RegionID = key.Item2.ID; if (value == null) { newElement.League = null; } else { newElement.LeagueID = value.ID; } context.LeagueDictionaryElements.Add(newElement); context.SaveChanges(); }